Skip to content

Instantly share code, notes, and snippets.

@eakst7
Created December 3, 2025 20:28
Show Gist options
  • Select an option

  • Save eakst7/3587cc67b3f8d648362a0b63f60e216f to your computer and use it in GitHub Desktop.

Select an option

Save eakst7/3587cc67b3f8d648362a0b63f60e216f to your computer and use it in GitHub Desktop.
Read a file line by line in Rust
fn main() {
let f = BufReader::new(File::open("text").unwrap());
for s in f.lines().map(|x| x.unwrap()) {
println!("{}", s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment