Function std::io::stderr 1.0.0[−][src]
Expand description
为当前进程的标准错误创建一个新的句柄。
此句柄未缓冲。
Note: Windows 可移植性注意事项
在控制台中操作时,此流的 Windows 实现不支持非 UTF-8 字节序列。 尝试写入无效的 UTF-8 字节将返回错误。
Examples
使用隐式同步:
use std::io::{self, Write};
fn main() -> io::Result<()> {
io::stderr().write_all(b"hello world")?;
Ok(())
}
Run使用显式同步:
use std::io::{self, Write};
fn main() -> io::Result<()> {
let stderr = io::stderr();
let mut handle = stderr.lock();
handle.write_all(b"hello world")?;
Ok(())
}
Run