You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
403 B
Rust
12 lines
403 B
Rust
4 years ago
|
use std::fs::File;
|
||
|
use std::io::{BufRead, BufReader};
|
||
|
fn main() {
|
||
|
// Open a file for reading
|
||
|
let f = File::open("file.txt").unwrap();
|
||
|
//Create a BufReader instance to optimize sys calls
|
||
|
let file_reader = BufReader::new(f);
|
||
|
// Read from standard input line-by-line
|
||
|
for single_line in file_reader.lines() {
|
||
|
println!("Line read from file :{}", single_line.unwrap());
|
||
|
}
|
||
|
}
|