Potentialy fix error string creation to only be done when needed.

This commit is contained in:
Csonka Mihaly 2020-03-23 17:04:32 +01:00
parent f214a561b8
commit 8c4100abea

View file

@ -13,13 +13,16 @@ pub fn handle_config(config: Config) -> Result<(), Error> {
Preview { line } => flows::preview::main(&line[..]),
Query { query } => {
let error_string = format!("Failed to filter cheatsheets for {}", &query);
flows::query::main(query.clone(), config).context(error_string)
let query_clone = query.clone();
flows::query::main(query.clone(), config)
.with_context(|| format!("Failed to filter cheatsheets for {}", query_clone))
}
Best { query, args } => {
let error_string = format!("Failed to execute snippet similar to {}", &query);
flows::best::main(query.clone(), args.to_vec(), config).context(error_string)
let query_clone = query.clone();
flows::best::main(query.clone(), args.to_vec(), config).with_context(|| {
format!("Failed to execute snippet similar to {}", query_clone)
})
}
Search { query } => flows::search::main(query.clone(), config)