Struct minigrep_test_package_001::Config[][src]

pub struct Config {
    pub query: String,
    pub filename: String,
    pub case_sensitive: bool,
}
Expand description

A fully valid minigrep command. Consists of a query to search for, a filename to search within, and a case_sensitive boolean to specify whether the search should ignore case or not

Fields

query: String

the query to search for

filename: String

the file to search within

case_sensitive: bool

whether query should be case sensitive or not

Implementations

Attempt to create a new Config from given arguments.

Examples

use std::{env, process};
use minigrep::Config;

// try to parse CLI arguments into minigrep config;
let config = Config::new(env::args()).unwrap_or_else(|err| {
    // if fail: convey error and exit
    eprintln!("Problem parsing arguments: {}", err);
    process::exit(1);
});

Errors

  • return Err(string) if a query string is missing from the args
  • return Err(string) if a file name is missing from the args

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.