📜  在 rust bufreader 中读取文件 - Rust 代码示例

📅  最后修改于: 2022-03-11 14:49:25.006000             🧑  作者: Mango

代码示例1
use std::fs::File;
use std::io::{self, prelude::*, BufReader};

fn main() -> io::Result<()> {
    let file = File::open("foo.txt")?;
    let reader = BufReader::new(file);

    for line in reader.lines() {
        println!("{}", line?);
    }

    Ok(())
}