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.
This commit is contained in:
Jonas Schievink 2020-10-08 23:23:07 +02:00 committed by GitHub
commit 2766b725d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,18 +92,14 @@ pub mod rt {
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error;
/// A collection of methods that are required to format a message into a stream.
/// A trait for writing or formatting into Unicode-accepting buffers or streams.
///
/// This trait is the type which this modules requires when formatting
/// information. This is similar to the standard library's [`io::Write`] trait,
/// but it is only intended for use in libcore.
/// This trait only accepts UTF-8encoded data and is not [flushable]. If you only
/// want to accept Unicode and you don't need flushing, you should implement this trait;
/// otherwise you should implement [`std::io::Write`].
///
/// This trait should generally not be implemented by consumers of the standard
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
/// [`io::Write`] trait is favored over implementing this trait.
///
/// [`write!`]: crate::write!
/// [`io::Write`]: ../../std/io/trait.Write.html
/// [`std::io::Write`]: ../../std/io/trait.Write.html
/// [flushable]: ../../std/io/trait.Write.html#tymethod.flush
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Write {
/// Writes a string slice into this writer, returning whether the write