Skip to content

Commit 2766b72

Browse files
Rollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum
Don't discourage implementing `core::fmt::Write` Fixes #76729. Explain when you should use it and when you should not.
2 parents 6b8d791 + c17d067 commit 2766b72

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

library/core/src/fmt/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,14 @@ pub type Result = result::Result<(), Error>;
9292
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
9393
pub struct Error;
9494

95-
/// A collection of methods that are required to format a message into a stream.
95+
/// A trait for writing or formatting into Unicode-accepting buffers or streams.
9696
///
97-
/// This trait is the type which this modules requires when formatting
98-
/// information. This is similar to the standard library's [`io::Write`] trait,
99-
/// but it is only intended for use in libcore.
97+
/// This trait only accepts UTF-8–encoded data and is not [flushable]. If you only
98+
/// want to accept Unicode and you don't need flushing, you should implement this trait;
99+
/// otherwise you should implement [`std::io::Write`].
100100
///
101-
/// This trait should generally not be implemented by consumers of the standard
102-
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
103-
/// [`io::Write`] trait is favored over implementing this trait.
104-
///
105-
/// [`write!`]: crate::write!
106-
/// [`io::Write`]: ../../std/io/trait.Write.html
101+
/// [`std::io::Write`]: ../../std/io/trait.Write.html
102+
/// [flushable]: ../../std/io/trait.Write.html#tymethod.flush
107103
#[stable(feature = "rust1", since = "1.0.0")]
108104
pub trait Write {
109105
/// Writes a string slice into this writer, returning whether the write

0 commit comments

Comments
 (0)