Created
October 14, 2017 16:13
-
-
Save mre/b44c7cfa63f9d8ca4258a3a27480d532 to your computer and use it in GitHub Desktop.
Print all words containing "rust"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::io::{BufReader, BufRead}; | |
fn main() { | |
let path = "/usr/share/dict/words"; | |
let f = File::open(path).expect("Can't open file"); | |
let buffered = BufReader::new(f); | |
for line_result in buffered.lines() { | |
let line = line_result.unwrap(); | |
if line.contains("rust") { | |
println!("{}", line); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment