~irimi1/learning-rust

ref: fb7ec1e9e060828105c40ef53acaeb2cb3b2ac69 learning-rust/projects/minigrep/src/main.rs -rw-r--r-- 488 bytes
fb7ec1e9Manuel Groß minigrep: Split program into main and lib 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::env;
use std::process;

use minigrep::Config;

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

    let config = Config::new(&args).unwrap_or_else(|err| {
        println!("Problem parsing arguments: {}", err);
        process::exit(1);
    });

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

    if let Err(e) = minigrep::run(config) {
        println!("Application error: {}", e);
        process::exit(1);
    }
}