~irimi1/learning-rust

ref: 5f333e2ae9b3d7dec1c9f41be602e45a1d13c1e3 learning-rust/projects/minigrep/src/main.rs -rw-r--r-- 379 bytes
5f333e2aManuel Groß minigrep: Read and print file contents 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::env;
use std::fs;

fn main() {
    let args: Vec<String> = env::args().collect();

    let query = &args[1];
    let filename = &args[2];

    println!("Searching for {}", query);
    println!("In file {}", filename);

    let contents = fs::read_to_string(filename)
        .expect("Something went wrong reading the file");

    println!("With text:\n{}", contents);
}