Skip to content

Commit

Permalink
clippy:option_map_unit_fn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jqnatividad committed Dec 31, 2023
1 parent e5c47a3 commit 3b87f5a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 3b87f5a

Please sign in to comment.