Fix more clippy lints

This commit is contained in:
Austen Adler 2023-04-18 13:41:56 -04:00
parent 030272f915
commit 7688c54fb8
4 changed files with 11 additions and 12 deletions

View File

@ -67,9 +67,9 @@ impl fmt::Display for LatLon {
} }
} }
impl Into<(f64, f64)> for LatLon { impl From<LatLon> for (f64, f64) {
fn into(self) -> (f64, f64) { fn from(val: LatLon) -> Self {
(self.lat, self.lon) (val.lat, val.lon)
} }
} }

View File

@ -112,7 +112,7 @@ impl TryFrom<LatLon> for Coordinate {
zone_letter, zone_letter,
easting, easting,
northing, northing,
latlon: latlon, latlon,
}) })
} }
} }

View File

@ -168,7 +168,8 @@ impl Address<'_> {
let mut words = vec![]; let mut words = vec![];
for word in word_components { for word in word_components {
words::get_word(word).map_or_else(|| errors.push(word.to_ascii_uppercase()), |w| words.push(w)); words::get_word(word)
.map_or_else(|| errors.push(word.to_ascii_uppercase()), |w| words.push(w));
} }
if !errors.is_empty() { if !errors.is_empty() {

View File

@ -27,7 +27,7 @@ pub struct EncodedAddress {
impl EncodedAddress { impl EncodedAddress {
#[wasm_bindgen(js_name = getCoordsType)] #[wasm_bindgen(js_name = getCoordsType)]
pub fn get_coords_type(&self) -> CoordinateType { pub fn get_coords_type(&self) -> CoordinateType {
self.src_coords.get_type().into() self.src_coords.get_type()
} }
/// Get the string representation of the encoded value /// Get the string representation of the encoded value
@ -43,7 +43,7 @@ impl EncodedAddress {
self.src_coords self.src_coords
// TODO: Remove the clone here // TODO: Remove the clone here
.clone() .clone()
.try_as_type(&coordinate_type.into()) .try_as_type(&coordinate_type)
.ok() .ok()
.map(|s| s.to_string()) .map(|s| s.to_string())
} }
@ -135,12 +135,10 @@ impl TryFrom<Coordinate> for EncodedAddress {
address: addr.to_string(), address: addr.to_string(),
lat_lon: Box::new([addr_lat, addr_lon]), lat_lon: Box::new([addr_lat, addr_lon]),
src_coords: src_coords src_coords: src_coords
.try_as_type(&src_coords.get_type().into()) .try_as_type(&src_coords.get_type())
.map_err(|e| e.to_string())? .map_err(|e| e.to_string())?,
.into(),
coordinate_urls: CoordinateUrls::try_from(addr_coordinates.latlon) coordinate_urls: CoordinateUrls::try_from(addr_coordinates.latlon)
.map_err(|e| e.to_string())? .map_err(|e| e.to_string())?,
.into(),
decimal_degrees: format!("{}, {}", addr_lat, addr_lon), decimal_degrees: format!("{}, {}", addr_lat, addr_lon),
all_coordinates: Coordinates::from(&addr_coordinates), all_coordinates: Coordinates::from(&addr_coordinates),
}) })