@@ -1336,7 +1336,7 @@ async fn geocode_main(args: Args) -> CliResult<()> {
1336
1336
}
1337
1337
1338
1338
/// check if index_file exists and ends with a .rkyv extension
1339
- fn check_index_file ( index_file : & String ) -> CliResult < ( ) > {
1339
+ fn check_index_file ( index_file : & str ) -> CliResult < ( ) > {
1340
1340
// check if index_file is a u16 with the values 500, 1000, 5000 or 15000
1341
1341
// if it is, return OK
1342
1342
if let Ok ( i) = index_file. parse :: < u16 > ( ) {
@@ -1722,7 +1722,7 @@ fn search_index(
1722
1722
}
1723
1723
1724
1724
// not a valid lat, long
1725
- return None ;
1725
+ None
1726
1726
}
1727
1727
1728
1728
#[ cached]
@@ -1766,19 +1766,19 @@ fn add_dyncols(
1766
1766
if let Some ( state_fips_code) = admin1. code . strip_prefix ( "US." ) {
1767
1767
// admin1 code is a US state code, the two-letter state code
1768
1768
// is the last two characters of the admin1 code
1769
- state_fips_code. to_string ( )
1769
+ state_fips_code
1770
1770
} else {
1771
1771
// admin1 code is not a US state code
1772
1772
// set to empty string
1773
- String :: new ( )
1773
+ ""
1774
1774
}
1775
1775
} else {
1776
1776
// no admin1 code
1777
1777
// set to empty string
1778
- String :: new ( )
1778
+ ""
1779
1779
} ;
1780
1780
// lookup US state FIPS code
1781
- record. push_field ( lookup_us_state_fips_code ( & us_state_code) . unwrap_or_default ( ) ) ;
1781
+ record. push_field ( lookup_us_state_fips_code ( us_state_code) . unwrap_or_default ( ) ) ;
1782
1782
} ,
1783
1783
"us_county_fips_code" => {
1784
1784
let us_county_fips_code = if let Some ( admin2) = cityrecord. admin2_division . as_ref ( )
@@ -1788,7 +1788,7 @@ fn add_dyncols(
1788
1788
// is the last three characters of the admin2 code
1789
1789
// start at index 7 to skip the US. prefix
1790
1790
// e.g. US.NY.061 -> 061
1791
- format ! ( "{:0>3}" , admin2. code[ 7 ..] . to_string ( ) )
1791
+ format ! ( "{:0>3}" , & admin2. code[ 7 ..] )
1792
1792
} else {
1793
1793
// admin2 code is not a US county code
1794
1794
// set to empty string
@@ -1864,11 +1864,11 @@ fn format_result(
1864
1864
} ,
1865
1865
"%state" | "%admin1" => nameslang. admin1name . clone ( ) ,
1866
1866
"%county" | "%admin2" => nameslang. admin2name . clone ( ) ,
1867
- "%country" => country. to_owned ( ) ,
1867
+ "%country" => country. to_string ( ) ,
1868
1868
"%country_name" => nameslang. countryname . clone ( ) ,
1869
- "%id" => format ! ( "{}" , cityrecord. id) ,
1870
- "%capital" => capital. to_owned ( ) ,
1871
- "%population" => format ! ( "{}" , cityrecord. population) ,
1869
+ "%id" => cityrecord. id . to_string ( ) ,
1870
+ "%capital" => capital. to_string ( ) ,
1871
+ "%population" => cityrecord. population . to_string ( ) ,
1872
1872
"%timezone" => cityrecord. timezone . to_string ( ) ,
1873
1873
"%cityrecord" => format ! ( "{cityrecord:?}" ) ,
1874
1874
"%admin1record" => format ! ( "{:?}" , cityrecord. admin_division) ,
@@ -1882,7 +1882,7 @@ fn format_result(
1882
1882
serde_json:: to_string ( cityrecord) . unwrap_or_else ( |_| "null" . to_string ( ) ) ;
1883
1883
let country_json =
1884
1884
serde_json:: to_string ( countryrecord) . unwrap_or_else ( |_| "null" . to_string ( ) ) ;
1885
- let us_fips_codes_json = get_us_fips_codes ( cityrecord, nameslang) . to_string ( ) ;
1885
+ let us_fips_codes_json = get_us_fips_codes ( cityrecord, nameslang) ;
1886
1886
format ! (
1887
1887
"{{\" cityrecord\" :{cr_json}, \" countryrecord\" :{country_json} \
1888
1888
\" us_fips_codes\" :{us_fips_codes_json}}}",
@@ -1955,13 +1955,13 @@ fn format_result(
1955
1955
"name" => cityrecord_map. insert ( "name" , nameslang. cityname . clone ( ) ) ,
1956
1956
"latitude" => cityrecord_map. insert ( "latitude" , cityrecord. latitude . to_string ( ) ) ,
1957
1957
"longitude" => cityrecord_map. insert ( "longitude" , cityrecord. longitude . to_string ( ) ) ,
1958
- "country" => cityrecord_map. insert ( "country" , country. to_owned ( ) ) ,
1958
+ "country" => cityrecord_map. insert ( "country" , country. to_string ( ) ) ,
1959
1959
"country_name" => {
1960
1960
cityrecord_map. insert ( "country_name" , nameslang. countryname . clone ( ) )
1961
1961
} ,
1962
1962
"admin1" => cityrecord_map. insert ( "admin1" , nameslang. admin1name . clone ( ) ) ,
1963
1963
"admin2" => cityrecord_map. insert ( "admin2" , nameslang. admin2name . clone ( ) ) ,
1964
- "capital" => cityrecord_map. insert ( "capital" , capital. to_owned ( ) ) ,
1964
+ "capital" => cityrecord_map. insert ( "capital" , capital. to_string ( ) ) ,
1965
1965
"timezone" => cityrecord_map. insert ( "timezone" , cityrecord. timezone . to_string ( ) ) ,
1966
1966
"population" => {
1967
1967
cityrecord_map. insert ( "population" , cityrecord. population . to_string ( ) )
@@ -1974,21 +1974,21 @@ fn format_result(
1974
1974
if let Some ( state_fips_code) = admin1. code . strip_prefix ( "US." ) {
1975
1975
// admin1 code is a US state code, the two-letter state code
1976
1976
// is the last two characters of the admin1 code
1977
- state_fips_code. to_string ( )
1977
+ state_fips_code
1978
1978
} else {
1979
1979
// admin1 code is not a US state code
1980
1980
// set to empty string
1981
- String :: new ( )
1981
+ ""
1982
1982
}
1983
1983
} else {
1984
1984
// no admin1 code
1985
1985
// set to empty string
1986
- String :: new ( )
1986
+ ""
1987
1987
} ;
1988
1988
cityrecord_map. insert (
1989
1989
"us_state_fips_code" ,
1990
- lookup_us_state_fips_code ( & us_state_code)
1991
- . unwrap_or_default ( )
1990
+ lookup_us_state_fips_code ( us_state_code)
1991
+ . unwrap_or ( "" )
1992
1992
. to_string ( ) ,
1993
1993
)
1994
1994
} ,
@@ -2002,7 +2002,7 @@ fn format_result(
2002
2002
// is the last three characters of the admin2 code
2003
2003
// start at index 7 to skip the US. prefix
2004
2004
// e.g. US.NY.061 -> 061
2005
- format ! ( "{:0>3}" , admin2. code[ 7 ..] . to_string ( ) )
2005
+ format ! ( "{:0>3}" , & admin2. code[ 7 ..] )
2006
2006
} else {
2007
2007
// admin2 code is not a US county code
2008
2008
// set to empty string
@@ -2238,18 +2238,18 @@ fn get_us_fips_codes(cityrecord: &CitiesRecord, nameslang: &NamesLang) -> serde_
2238
2238
if let Some ( state_fips_code) = admin1. code . strip_prefix ( "US." ) {
2239
2239
// admin1 code is a US state code, the two-letter state code
2240
2240
// is the last two characters of the admin1 code
2241
- state_fips_code. to_string ( )
2241
+ state_fips_code
2242
2242
} else {
2243
2243
// admin1 code is not a US state code
2244
2244
// set to empty string
2245
- String :: new ( )
2245
+ ""
2246
2246
}
2247
2247
} else {
2248
2248
// no admin1 code
2249
2249
// set to empty string
2250
- String :: new ( )
2250
+ ""
2251
2251
} ;
2252
- let us_state_fips_code = lookup_us_state_fips_code ( & us_state_code) . unwrap_or ( "null" ) ;
2252
+ let us_state_fips_code = lookup_us_state_fips_code ( us_state_code) . unwrap_or ( "null" ) ;
2253
2253
2254
2254
let us_county_code = match cityrecord. admin2_division . as_ref ( ) {
2255
2255
Some ( admin2) => {
@@ -2258,7 +2258,7 @@ fn get_us_fips_codes(cityrecord: &CitiesRecord, nameslang: &NamesLang) -> serde_
2258
2258
// is the last three characters of the admin2 code
2259
2259
// start at index 7 to skip the US. prefix
2260
2260
// e.g. US.NY.061 -> 061
2261
- format ! ( "{:0>3}" , admin2. code[ 7 ..] . to_string ( ) )
2261
+ format ! ( "{:0>3}" , & admin2. code[ 7 ..] )
2262
2262
} else {
2263
2263
// admin2 code is not a US county code
2264
2264
// set to empty string
0 commit comments