diff options
| author | Elias Holzmann <9659253+EliasHolzmann@users.noreply.github.com> | 2022-04-30 02:41:32 +0200 |
|---|---|---|
| committer | Elias Holzmann <9659253+EliasHolzmann@users.noreply.github.com> | 2022-05-01 15:27:41 +0200 |
| commit | f3b86c37ebdddbc7555ba560b6c4b4f4d44f991d (patch) | |
| tree | 84fe3f3672c8e9865c2df48f2043a8809823d896 | |
| parent | c70f3ab5e53916a2e0210a24b67c64f2b700a06f (diff) | |
| download | rust-f3b86c37ebdddbc7555ba560b6c4b4f4d44f991d.tar.gz rust-f3b86c37ebdddbc7555ba560b6c4b4f4d44f991d.zip | |
std::fmt: Improved list of formatting macros
Two improvements: 1. write! can not only receive a `io::Write`, but also a `fmt::Write` as first argument. 2. The description texts now contain links to the actual macros for easier navigation.
| -rw-r--r-- | library/alloc/src/fmt.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 635a3ffa3c5..73b75ea4d83 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -460,7 +460,7 @@ //! //! ```ignore (only-for-syntax-highlight) //! format! // described above -//! write! // first argument is a &mut io::Write, the destination +//! write! // first argument is either a &mut io::Write or a &mut fmt::Write, the destination //! writeln! // same as write but appends a newline //! print! // the format string is printed to the standard output //! println! // same as print but appends a newline @@ -471,11 +471,11 @@ //! //! ### `write!` //! -//! This and [`writeln!`] are two macros which are used to emit the format string +//! [`write!`] and [`writeln!`] are two macros which are used to emit the format string //! to a specified stream. This is used to prevent intermediate allocations of //! format strings and instead directly write the output. Under the hood, this //! function is actually invoking the [`write_fmt`] function defined on the -//! [`std::io::Write`] trait. Example usage is: +//! [`std::io::Write`] and the [`std::fmt::Write`] trait. Example usage is: //! //! ``` //! # #![allow(unused_must_use)] @@ -502,7 +502,7 @@ //! //! ### `format_args!` //! -//! This is a curious macro used to safely pass around +//! [`format_args!`] is a curious macro used to safely pass around //! an opaque object describing the format string. This object //! does not require any heap allocations to create, and it only //! references information on the stack. Under the hood, all of @@ -540,10 +540,12 @@ //! [`to_string`]: crate::string::ToString::to_string "ToString::to_string" //! [`write_fmt`]: ../../std/io/trait.Write.html#method.write_fmt //! [`std::io::Write`]: ../../std/io/trait.Write.html +//! [`std::fmt::Write`]: ../../std/fmt/trait.Write.html //! [`print!`]: ../../std/macro.print.html "print!" //! [`println!`]: ../../std/macro.println.html "println!" //! [`eprint!`]: ../../std/macro.eprint.html "eprint!" //! [`eprintln!`]: ../../std/macro.eprintln.html "eprintln!" +//! [`format_args!`]: ../../std/macro.format_args.html "format_args!" //! [`fmt::Arguments`]: Arguments "fmt::Arguments" //! [`format`]: format() "fmt::format" |
