rustbook

Toy programs and snippets for The Rust Programming Language book
Log | Files | Refs

main.rs (386B)


      1 use std::env;
      2 use std::process;
      3 
      4 use minigrep::Config;
      5 
      6 fn main() {
      7     let args: Vec<String> = env::args().collect();
      8 
      9     let cf = Config::new(args).unwrap_or_else(|err| {
     10         eprintln!("Failed to parse arguments: {}", err);
     11         process::exit(1);
     12     });
     13     if let Err(e) = minigrep::run(cf) {
     14         eprintln!("Application error: {}", e);
     15         process::exit(1);
     16     }
     17 }