Skip to content

Commit

Permalink
clippy: apply suggestions
Browse files Browse the repository at this point in the history
warning: variables can be used directly in the `format!` string
    --> src/cmd/geocode.rs:1739:17
     |
1739 | /                 format!(
1740 | |                     "{{\"cityrecord\":{}, \"countryrecord\":{} \"us_fips_codes\":{}}}",
1741 | |                     cr_json, country_json, us_fips_codes_json
1742 | |                 )
     | |_________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
     = note: `-W clippy::uninlined-format-args` implied by `-W clippy::pedantic`
     = help: to override `-W clippy::pedantic` add `#[allow(clippy::uninlined_format_args)]`

warning: variables can be used directly in the `format!` string
    --> src/cmd/geocode.rs:1754:17
     |
1754 | /                 format!(
1755 | |                     "{{\n  \"cityrecord\":{},\n  \"countryrecord\":{}\n \"us_fips_codes\":{}\n}}",
1756 | |                     cr_json, country_json, us_fips_codes_json
1757 | |                 )
     | |_________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

warning: unnecessary closure used to substitute value for `Option::None`
    --> src/cmd/geocode.rs:2119:30
     |
2119 |     let us_state_fips_code = lookup_us_state_fips_code(&us_state_code).unwrap_or_else(|| "null");
     |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------
     |                                                                        |
     |                                                                        help: use `unwrap_or(..)` instead: `unwrap_or("null")`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
     = note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
  • Loading branch information
jqnatividad committed Oct 24, 2023
1 parent 0ea0030 commit df6318c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,10 +1735,9 @@ fn format_result(
let country_json =
serde_json::to_string(countryrecord).unwrap_or_else(|_| "null".to_string());
let us_fips_codes_json = get_us_fips_codes(cityrecord, nameslang).to_string();

format!(
"{{\"cityrecord\":{}, \"countryrecord\":{} \"us_fips_codes\":{}}}",
cr_json, country_json, us_fips_codes_json
"{{\"cityrecord\":{cr_json}, \"countryrecord\":{country_json} \
\"us_fips_codes\":{us_fips_codes_json}}}",
)
},
"%pretty-json" => {
Expand All @@ -1752,8 +1751,8 @@ fn format_result(
let us_fips_codes_json = serde_json::to_string_pretty(&us_fips_codes)
.unwrap_or_else(|_| "null".to_string());
format!(
"{{\n \"cityrecord\":{},\n \"countryrecord\":{}\n \"us_fips_codes\":{}\n}}",
cr_json, country_json, us_fips_codes_json
"{{\n \"cityrecord\":{cr_json},\n \"countryrecord\":{country_json}\n \
\"us_fips_codes\":{us_fips_codes_json}\n}}",
)
},
_ => {
Expand Down Expand Up @@ -2116,7 +2115,7 @@ fn get_us_fips_codes(cityrecord: &CitiesRecord, nameslang: &NamesLang) -> serde_
// set to empty string
String::new()
};
let us_state_fips_code = lookup_us_state_fips_code(&us_state_code).unwrap_or_else(|| "null");
let us_state_fips_code = lookup_us_state_fips_code(&us_state_code).unwrap_or("null");

let us_county_code = match cityrecord
.admin2_division
Expand Down

0 comments on commit df6318c

Please sign in to comment.