diff --git a/src/main.rs b/src/main.rs index 2aa1996..8fc4e03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ struct App { impl App { /// check if word consists only of letters in query - fn check_word(&self, word: &str) -> Option { + fn check_word<'a>(&self, word: &'a str) -> Option<&'a str> { let mut query = self.query.clone(); word.chars() .try_for_each(|c| { @@ -19,17 +19,19 @@ impl App { query.remove(position); Some(()) }) - .and(Some(word.to_string())) + .and(Some(word)) } } fn main() { let app: App = argh::from_env(); + let start = std::time::Instant::now(); let mut results = WORDS .lines() .filter_map(|line| app.check_word(line)) - .collect::>(); + .collect::>(); + eprintln!("search took: {:?}", start.elapsed()); results.sort_by(|a, b| { a.len()