Skip to content

Commit f3b86c3

Browse files
committed
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.
1 parent c70f3ab commit f3b86c3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

library/alloc/src/fmt.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@
460460
//!
461461
//! ```ignore (only-for-syntax-highlight)
462462
//! format! // described above
463-
//! write! // first argument is a &mut io::Write, the destination
463+
//! write! // first argument is either a &mut io::Write or a &mut fmt::Write, the destination
464464
//! writeln! // same as write but appends a newline
465465
//! print! // the format string is printed to the standard output
466466
//! println! // same as print but appends a newline
@@ -471,11 +471,11 @@
471471
//!
472472
//! ### `write!`
473473
//!
474-
//! This and [`writeln!`] are two macros which are used to emit the format string
474+
//! [`write!`] and [`writeln!`] are two macros which are used to emit the format string
475475
//! to a specified stream. This is used to prevent intermediate allocations of
476476
//! format strings and instead directly write the output. Under the hood, this
477477
//! function is actually invoking the [`write_fmt`] function defined on the
478-
//! [`std::io::Write`] trait. Example usage is:
478+
//! [`std::io::Write`] and the [`std::fmt::Write`] trait. Example usage is:
479479
//!
480480
//! ```
481481
//! # #![allow(unused_must_use)]
@@ -502,7 +502,7 @@
502502
//!
503503
//! ### `format_args!`
504504
//!
505-
//! This is a curious macro used to safely pass around
505+
//! [`format_args!`] is a curious macro used to safely pass around
506506
//! an opaque object describing the format string. This object
507507
//! does not require any heap allocations to create, and it only
508508
//! references information on the stack. Under the hood, all of
@@ -540,10 +540,12 @@
540540
//! [`to_string`]: crate::string::ToString::to_string "ToString::to_string"
541541
//! [`write_fmt`]: ../../std/io/trait.Write.html#method.write_fmt
542542
//! [`std::io::Write`]: ../../std/io/trait.Write.html
543+
//! [`std::fmt::Write`]: ../../std/fmt/trait.Write.html
543544
//! [`print!`]: ../../std/macro.print.html "print!"
544545
//! [`println!`]: ../../std/macro.println.html "println!"
545546
//! [`eprint!`]: ../../std/macro.eprint.html "eprint!"
546547
//! [`eprintln!`]: ../../std/macro.eprintln.html "eprintln!"
548+
//! [`format_args!`]: ../../std/macro.format_args.html "format_args!"
547549
//! [`fmt::Arguments`]: Arguments "fmt::Arguments"
548550
//! [`format`]: format() "fmt::format"
549551

0 commit comments

Comments
 (0)