Struct std::io::Stderr1.0.0[−][src]

pub struct Stderr { /* fields omitted */ }
Expand description

进程的标准错误流的句柄。

有关更多信息,请参见 io::stderr 方法。

Note: Windows 可移植性注意事项

在控制台中操作时,此流的 Windows 实现不支持非 UTF-8 字节序列。 尝试写入无效的 UTF-8 字节将返回错误。

Implementations

将此句柄锁定到标准错误流,返回可写防护。

当返回的锁离开作用域时,将释放该锁。 返回的防护还实现 Write trait 来写入数据。

Examples

use std::io::{self, Write};

fn foo() -> io::Result<()> {
    let stderr = io::stderr();
    let mut handle = stderr.lock();

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

    Ok(())
}
Run
🔬 This is a nightly-only experimental API. (stdio_locked #86845)

锁定并使用此句柄到标准错误流,返回可写保护。

当返回的守卫作用域解除锁定。 返回的防护还实现 Write trait 来写入数据。

Examples

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

fn foo() -> io::Result<()> {
    let stderr = io::stderr();
    let mut handle = stderr.into_locked();

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

    Ok(())
}
Run

Trait Implementations

This is supported on Unix only.

提取原始文件描述符。 Read more

This is supported on WASI only.
🔬 This is a nightly-only experimental API. (wasi_ext #71213)

提取原始文件描述符。 Read more

This is supported on Windows only.

提取原始句柄,无需任何所有权。

使用给定的格式化程序格式化该值。 Read more

在此 writer 中写入一个缓冲区,返回写入的字节数。 Read more

类似于 write,不同之处在于它是从缓冲区片段中写入数据的。 Read more

🔬 This is a nightly-only experimental API. (can_vector #69941)

确定此 Writer 是否具有有效的 write_vectored 实现。 Read more

刷新此输出流,确保所有中间缓冲的内容均到达其目的地。 Read more

尝试将整个缓冲区写入此 writer。 Read more

🔬 This is a nightly-only experimental API. (write_all_vectored #70436)

尝试将多个缓冲区写入此 writer。 Read more

将格式化的字符串写入此 writer,返回遇到的任何错误。 Read more

为此 Write 实例创建 “by reference” 适配器。 Read more

在此 writer 中写入一个缓冲区,返回写入的字节数。 Read more

类似于 write,不同之处在于它是从缓冲区片段中写入数据的。 Read more

🔬 This is a nightly-only experimental API. (can_vector #69941)

确定此 Writer 是否具有有效的 write_vectored 实现。 Read more

刷新此输出流,确保所有中间缓冲的内容均到达其目的地。 Read more

尝试将整个缓冲区写入此 writer。 Read more

🔬 This is a nightly-only experimental API. (write_all_vectored #70436)

尝试将多个缓冲区写入此 writer。 Read more

将格式化的字符串写入此 writer,返回遇到的任何错误。 Read more

为此 Write 实例创建 “by reference” 适配器。 Read more

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。