lights0123 před 4 roky
rodič
revize
6cb5870384
4 změnil soubory, kde provedl 34 přidání a 3 odebrání
  1. 14 1
      README.md
  2. 14 0
      README.tpl
  3. 2 2
      src/lib.rs
  4. 4 0
      src/output.rs

+ 14 - 1
README.md

@@ -89,7 +89,6 @@ If you have access to [`std`], i.e. not an embedded platform, you can use
 Now, add your logic:
 
 ```rust
-#
 use printf_compat::{format, output};
 let mut s = String::new();
 let bytes_written = format(str, args.as_va_list(), output::fmt_write(&mut s));
@@ -111,3 +110,17 @@ error.
 [`defmt`]: https://defmt.ferrous-systems.com/
 
 License: MIT OR Apache-2.0
+
+[`core::fmt`]: https://doc.rust-lang.org/core/fmt/index.html
+[`String`]: https://doc.rust-lang.org/std/string/struct.String.html
+[std::io::stdout]: https://doc.rust-lang.org/std/io/fn.stdout.html
+[`std`]: https://doc.rust-lang.org/std/index.html
+[`std::os::raw`]: https://doc.rust-lang.org/stable/std/os/raw/index.html
+[`cty`]: https://docs.rs/cty/0.2/cty/
+[output::fmt_write]: https://docs.rs/printf-compat/0.1.0/printf_compat/output/fn.fmt_write.html
+[`output::fmt_write`]: https://docs.rs/printf-compat/0.1.0/printf_compat/output/fn.fmt_write.html
+[output::fmt_write#differences]: https://docs.rs/printf-compat/0.1.0/printf_compat/output/fn.fmt_write.html#differences
+[output::io_write]: https://docs.rs/printf-compat/0.1.0/printf_compat/output/fn.io_write.html
+[`output`]: https://docs.rs/printf-compat/0.1.0/printf_compat/output/index.html
+[`format()`]: https://docs.rs/printf-compat/0.1.0/printf_compat/fn.format.html
+[`Argument`]: https://docs.rs/printf-compat/0.1.0/printf_compat/argument/struct.Argument.html

+ 14 - 0
README.tpl

@@ -6,3 +6,17 @@
 {{readme}}
 
 License: {{license}}
+
+[`core::fmt`]: https://doc.rust-lang.org/core/fmt/index.html
+[`String`]: https://doc.rust-lang.org/std/string/struct.String.html
+[std::io::stdout]: https://doc.rust-lang.org/std/io/fn.stdout.html
+[`std`]: https://doc.rust-lang.org/std/index.html
+[`std::os::raw`]: https://doc.rust-lang.org/stable/std/os/raw/index.html
+[`cty`]: https://docs.rs/cty/0.2/cty/
+[output::fmt_write]: https://docs.rs/printf-compat/{{version}}/printf_compat/output/fn.fmt_write.html
+[`output::fmt_write`]: https://docs.rs/printf-compat/{{version}}/printf_compat/output/fn.fmt_write.html
+[output::fmt_write#differences]: https://docs.rs/printf-compat/{{version}}/printf_compat/output/fn.fmt_write.html#differences
+[output::io_write]: https://docs.rs/printf-compat/{{version}}/printf_compat/output/fn.io_write.html
+[`output`]: https://docs.rs/printf-compat/{{version}}/printf_compat/output/index.html
+[`format()`]: https://docs.rs/printf-compat/{{version}}/printf_compat/fn.format.html
+[`Argument`]: https://docs.rs/printf-compat/{{version}}/printf_compat/argument/struct.Argument.html

+ 2 - 2
src/lib.rs

@@ -48,7 +48,8 @@
 //! ## 🧹 Tested
 //!
 //! A wide [test suite] is used to ensure that many different possibilities are
-//! identical to glibc's `printf`. [Differences are documented][output::fmt_write#differences].
+//! identical to glibc's `printf`. [Differences are
+//! documented][output::fmt_write#differences].
 //!
 //! # Getting Started
 //!
@@ -87,7 +88,6 @@
 //! ```rust
 //! # #![feature(c_variadic)]
 //! # use cty::{c_char, c_int};
-//! #
 //! # #[no_mangle]
 //! # unsafe extern "C" fn c_library_print(str: *const c_char, mut args: ...) -> c_int {
 //! use printf_compat::{format, output};

+ 4 - 0
src/output.rs

@@ -293,6 +293,10 @@ pub fn fmt_write(w: &mut impl fmt::Write) -> impl FnMut(Argument) -> c_int + '_
 /// [`fmt_write`], but may be the only option.
 ///
 /// This shares the same caveats as [`fmt_write`].
+///
+/// # Safety
+///
+/// [`VaList`]s are *very* unsafe. The passed `format` and `args` parameter must be a valid [`printf` format string](http://www.cplusplus.com/reference/cstdio/printf/).
 pub unsafe fn display<'a, 'b>(
     format: *const c_char,
     va_list: VaList<'a, 'b>,