Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tokio/src/io/stderr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cfg_io_std! {
///
/// #[tokio::main]
/// async fn main() -> io::Result<()> {
/// let mut stderr = io::stdout();
/// let mut stderr = io::stderr();
/// stderr.write_all(b"Print some error here.").await?;
/// Ok(())
/// }
Expand All @@ -50,6 +50,20 @@ cfg_io_std! {
/// to occur as a single write, so multiple threads writing data with
/// [`write_all`] may result in interleaved output.
///
/// Note that unlike [`std::io::stderr`], each call to this `stderr()`
/// produces a new writer, so for example, this program does **not** flush stderr:
///
/// ```no_run
/// # use tokio::io::AsyncWriteExt;
/// # #[tokio::main]
/// # async fn main() -> std::io::Result<()> {
/// tokio::io::stderr().write_all(b"aa").await?;
/// tokio::io::stderr().flush().await?;
/// # Ok(())
/// # }
/// ```
///
/// [`std::io::stderr`]: std::io::stderr
/// [`AsyncWrite`]: AsyncWrite
/// [`write_all`]: crate::io::AsyncWriteExt::write_all()
///
Expand Down
14 changes: 14 additions & 0 deletions tokio/src/io/stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ cfg_io_std! {
/// to occur as a single write, so multiple threads writing data with
/// [`write_all`] may result in interleaved output.
///
/// Note that unlike [`std::io::stdout`], each call to this `stdout()`
/// produces a new writer, so for example, this program does **not** flush stdout:
///
/// ```no_run
/// # use tokio::io::AsyncWriteExt;
/// # #[tokio::main]
/// # async fn main() -> std::io::Result<()> {
/// tokio::io::stdout().write_all(b"aa").await?;
/// tokio::io::stdout().flush().await?;
/// # Ok(())
/// # }
/// ```
///
/// [`std::io::stdout`]: std::io::stdout
/// [`AsyncWrite`]: AsyncWrite
/// [`write_all`]: crate::io::AsyncWriteExt::write_all()
///
Expand Down