Struct std::io::Chain 1.0.0[−][src]
pub struct Chain<T, U> { /* fields omitted */ }Implementations
消耗 Chain,返回包装的 readers。
Examples
use std::io;
use std::io::prelude::*;
use std::fs::File;
fn main() -> io::Result<()> {
let mut foo_file = File::open("foo.txt")?;
let mut bar_file = File::open("bar.txt")?;
let chain = foo_file.chain(bar_file);
let (foo_file, bar_file) = chain.into_inner();
Ok(())
}Run获取此 Chain 中的底层 readers 的引用。
Examples
use std::io;
use std::io::prelude::*;
use std::fs::File;
fn main() -> io::Result<()> {
let mut foo_file = File::open("foo.txt")?;
let mut bar_file = File::open("bar.txt")?;
let chain = foo_file.chain(bar_file);
let (foo_file, bar_file) = chain.get_ref();
Ok(())
}Run获取此 Chain 中的底层 readers 的可变引用。
应注意避免修改底层 readers 的内部 I/O 状态,因为这样做可能会破坏该 Chain 的内部状态。
Examples
use std::io;
use std::io::prelude::*;
use std::fs::File;
fn main() -> io::Result<()> {
let mut foo_file = File::open("foo.txt")?;
let mut bar_file = File::open("bar.txt")?;
let mut chain = foo_file.chain(bar_file);
let (foo_file, bar_file) = chain.get_mut();
Ok(())
}RunTrait Implementations
返回内部缓冲区的内容,如果内部缓冲区为空,则使用内部 reader 中的更多数据填充内部缓冲区。 Read more
🔬 This is a nightly-only experimental API. (buf_read_has_data_left #86423)
recently added
检查底层 Read 是否有任何数据可供读取。 Read more
将所有字节读入 buf,直到到达定界符 byte 或 EOF。 Read more
读取所有字节,直到到达换行符 (0xA 字节),然后将它们追加到提供的缓冲区中。 Read more
返回对该字节 byte 上的 reader 拆分内容的迭代器。 Read more