Struct std::io::StdinLock 1.0.0[−][src]
pub struct StdinLock<'a> { /* fields omitted */ }Expand description
Stdin 句柄的锁定引用。
该句柄同时实现 Read 和 BufRead traits,并通过 Stdin::lock 方法构造。
Note: Windows 可移植性注意事项
在控制台中操作时,此流的 Windows 实现不支持非 UTF-8 字节序列。 尝试读取无效的 UTF-8 字节将返回错误。
Examples
use std::io::{self, Read}; fn main() -> io::Result<()> { let mut buffer = String::new(); let stdin = io::stdin(); // 我们在这里得到 `Stdin`。 { let mut handle = stdin.lock(); // 我们在这里得到 `StdinLock`。 handle.read_to_string(&mut buffer)?; } // `StdinLock` 在这里丢弃。 Ok(()) }Run
Trait Implementations
This is supported on Unix only.
This is supported on WASI only.
This is supported on Windows only.
提取原始句柄,无需任何所有权。
返回内部缓冲区的内容,如果内部缓冲区为空,则使用内部 reader 中的更多数据填充内部缓冲区。 Read more
将所有字节读入 buf,直到到达定界符 byte 或 EOF。 Read more
读取所有字节,直到到达换行符 (0xA 字节),然后将它们附加到提供的缓冲区中。 Read more
🔬 This is a nightly-only experimental API. (buf_read_has_data_left #86423)
recently added
检查底层 Read 是否有任何数据可供读取。 Read more
返回对该字节 byte 上的 reader 拆分内容的迭代器。 Read more