Convey Config
creation errors using a Result
This commit is contained in:
parent
dd00502383
commit
bb076d6cb6
1 changed files with 3 additions and 3 deletions
|
@ -21,14 +21,14 @@ struct Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
fn new(args: &[String]) -> Config {
|
fn build(args: &[String]) -> Result<Config, &'static str> {
|
||||||
if args.len() < 3 {
|
if args.len() < 3 {
|
||||||
panic!("not enough arguments");
|
return Err("not enough arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = args[1].clone();
|
let query = args[1].clone();
|
||||||
let file_path = args[2].clone();
|
let file_path = args[2].clone();
|
||||||
|
|
||||||
Config { query, file_path }
|
Ok(Config { query, file_path })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue