10 pub fn new(args
: &[String
]) -> Result
<Config
, &str> {
12 return Err("not enough arguments");
15 let query
= args
[1].clone();
16 let filename
= args
[2].clone();
18 Ok(Config { query, filename }
)
22 pub fn run(config
: Config
) -> Result
<(), Box
<dyn Error
>> {
23 let contents
= fs
::read_to_string(config
.filename
)?
;
29 pub fn search(query
: &str, contents
: &str) -> Vec
<&str> {
43 safe, fast, productive.
46 assert_eq
!(vec
!["safe, fast, productive."], search(query
, contents
));