Skip to content

Commit

Permalink
geocode: apply clippy::ref_option suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Oct 6, 2024
1 parent 927f1e2 commit 3f9f0a5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,8 +1179,8 @@ async fn geocode_main(args: Args) -> CliResult<()> {
&args.flag_language,
min_score,
k_weight,
&country_filter_list,
&admin1_filter_list,
country_filter_list.as_ref(),
admin1_filter_list.as_ref(),
&column_values,
&mut record,
);
Expand Down Expand Up @@ -1212,8 +1212,8 @@ async fn geocode_main(args: Args) -> CliResult<()> {
&args.flag_language,
min_score,
k_weight,
&country_filter_list,
&admin1_filter_list,
country_filter_list.as_ref(),
admin1_filter_list.as_ref(),
&column_values,
&mut record,
);
Expand Down Expand Up @@ -1423,16 +1423,16 @@ fn search_index(
lang_lookup: &str,
min_score: Option<f32>,
k: Option<f32>,
country_filter_list: &Option<Vec<String>>,
admin1_filter_list: &Option<Vec<Admin1Filter>>,
country_filter_list: Option<&Vec<String>>,
admin1_filter_list: Option<&Vec<Admin1Filter>>,
column_values: &[&str], //&Vec<&str>,
record: &mut csv::StringRecord,
) -> Option<String> {
if mode == GeocodeSubCmd::Suggest || mode == GeocodeSubCmd::SuggestNow {
let search_result: Vec<&CitiesRecord>;
let cityrecord = if admin1_filter_list.is_none() {
// no admin1 filter, run a search for 1 result (top match)
search_result = engine.suggest(cell, 1, min_score, country_filter_list.as_deref());
search_result = engine.suggest(cell, 1, min_score, country_filter_list.map(|v| &**v));
let Some(cr) = search_result.into_iter().next() else {
// no results, so return early with None
return None;
Expand All @@ -1444,7 +1444,7 @@ fn search_index(
cell,
SUGGEST_ADMIN1_LIMIT,
min_score,
country_filter_list.as_deref(),
country_filter_list.map(|v| &**v),
);

// first, get the first result and store that in cityrecord
Expand Down Expand Up @@ -1559,7 +1559,8 @@ fn search_index(
let lat = loccaps[1].to_string().parse::<f32>().unwrap_or_default();
let long = loccaps[2].to_string().parse::<f32>().unwrap_or_default();
if (-90.0..=90.0).contains(&lat) && (-180.0..=180.0).contains(&long) {
let search_result = engine.reverse((lat, long), 1, k, country_filter_list.as_deref());
let search_result =
engine.reverse((lat, long), 1, k, country_filter_list.map(|v| &**v));
let cityrecord = (match search_result {
Some(search_result) => search_result.into_iter().next().map(|ri| ri.city),
None => return None,
Expand Down

0 comments on commit 3f9f0a5

Please sign in to comment.