pub fn stderr_locked() -> StderrLock<'static>Notable traits for StderrLock<'_>impl Write for StderrLock<'_>
🔬 This is a nightly-only experimental API. (stdio_locked #86845)
Expand description

Constructs a new locked handle to the standard error of the current process.

This handle is not buffered.

Note: Windows Portability Consideration

When operating in a console, the Windows implementation of this stream does not support non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return an error.

Example

#![feature(stdio_locked)]
use std::io::{self, Write};

fn main() -> io::Result<()> {
    let mut handle = io::stderr_locked();

    handle.write_all(b"hello world")?;

    Ok(())
}
Run