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, BufRead};
fn main() -> io::Result<()> {
let mut buffer = String::new();
let stdin = io::stdin(); // 我们在这里得到 `Stdin`。
{
let mut handle = stdin.lock(); // 我们在这里得到 `StdinLock`。
handle.read_line(&mut buffer)?;
} // `StdinLock` 被丢弃在这里。
Ok(())
}
RunTrait Implementations
提取原始句柄,无需任何所有权。
与 read
相似,不同之处在于它读入缓冲区的一部分。 Read more
读取所有字节,直到此源中的 EOF 为止,然后将它们放入 buf
。 Read more
读取这个源中的所有字节,直到 EOF 为止,然后将它们追加到 buf
。 Read more
为这个 Read
实例创建一个 “by reference” 适配器。 Read more
创建一个适配器,将这个流与另一个链接起来。 Read more