summaryrefslogblamecommitdiff
path: root/meap/meap-code/ch2/ch2-bufreader-lines.rs
blob: 24582af7fafe450c4225ace73d7595effe322452 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                      
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;

fn main() {
  let f = File::open("readme.md").unwrap();
  let reader = BufReader::new(f);

  for line_ in reader.lines() { // <1>
    let line = line_.unwrap(); // <2>
    println!("{} ({} bytes long)", line, line.len());
  }
}