diff --git a/geo-types/src/lib.rs b/geo-types/src/lib.rs index 6b8aebf..1bf0c05 100644 --- a/geo-types/src/lib.rs +++ b/geo-types/src/lib.rs @@ -5,7 +5,7 @@ pub struct Latitude(f32); impl From for Latitude { fn from(val: f32) -> Self { - if val > 90.0 || val < -90.0 { + if !(-90.0..=90.0).contains(&val) { panic!("Latitude is outside of range"); } Self(val) @@ -23,7 +23,7 @@ pub struct Longitude(f32); impl From for Longitude { fn from(val: f32) -> Self { - if val > 180.0 || val < -180.0 { + if !(-180.0..=180.0).contains(&val) { panic!("Longitude is outside fo range"); } Self(val)