summaryrefslogtreecommitdiff
path: root/meap/meap-code/ch2/ch2-read-file-iter-lines.rs
blob: f59fa9e1557ed8c2444b9d06b19ce2cfc28d586d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#[allow(unused_mut)]

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

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

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