Skip to content

Commit 112003c

Browse files
committed
read poem file
1 parent ca4eff2 commit 112003c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

poem.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
I'm nobody! Who are you?
2+
Are you nobody, too?
3+
Then there's a pair of us - don't tell!
4+
They'd banish us, you know.
5+
6+
How dreary to be somebody!
7+
How public, like a frog
8+
To tell your name the livelong day
9+
To an admiring bog!

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::env;
1+
use std::{env, fs};
22

33
fn main() {
44
let args: Vec<String> = env::args().collect();
@@ -7,5 +7,10 @@ fn main() {
77
let file_path = &args[2];
88

99
println!("Searching for {}", query);
10-
println!("In file {}", file_path);
10+
println!("In file {}\n", file_path);
11+
12+
let contents = fs::read_to_string(file_path)
13+
.expect("Should be able to read the file!");
14+
15+
println!("With text contents:\n{}", contents);
1116
}

0 commit comments

Comments
 (0)