From 3b87f5a55ef801af5aecbe95314500d5cb29083f Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:58:41 -0500 Subject: [PATCH] `clippy`:option_map_unit_fn warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> src/cmd/geocode.rs:1379:5 | 1379 | // engine.metadata.as_ref().map(|m| { 1380 | || let now = std::time::SystemTime::now(); 1381 | || let age = now.duration_since(m.created_at).unwrap(); 1382 | || progressbar.println(format!( ... || 1385 | || )); 1386 | || }); | ||______^- help: try: `if let Some(m) = engine.metadata.as_ref() { ... }` | |______| | | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn = note: `#[warn(clippy::option_map_unit_fn)]` on by default warning: `qsv` (bin "qsv") generated 1 warning --- src/cmd/geocode.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/geocode.rs b/src/cmd/geocode.rs index 46cccf4e5..88472f523 100644 --- a/src/cmd/geocode.rs +++ b/src/cmd/geocode.rs @@ -1376,14 +1376,14 @@ async fn load_engine(geocode_index_file: PathBuf, progressbar: &ProgressBar) -> .load_from(geocode_index_file) .map_err(|e| format!("On load index file: {e}"))?; - engine.metadata.as_ref().map(|m| { + if let Some(metadata) = &engine.metadata { let now = std::time::SystemTime::now(); - let age = now.duration_since(m.created_at).unwrap(); + let age = now.duration_since(metadata.created_at).unwrap(); progressbar.println(format!( "Geonames index loaded. Age: {}", indicatif::HumanDuration(age) )); - }); + } Ok(engine) }