pub struct GeoLocation { /* private fields */ }
Expand description
A data structure containing a single physical geo-location.
Implementations§
Source§impl GeoLocation
impl GeoLocation
Sourcepub fn latitude(self) -> f32
pub fn latitude(self) -> f32
Get the latitude.
§Examples
let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(12.345, geo.latitude());
Sourcepub fn longitude(self) -> f32
pub fn longitude(self) -> f32
Get the longitude
§Examples
let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(-98.765, geo.longitude());
Sourcepub fn new(latitude: f32, longitude: f32) -> Result<Self, String>
pub fn new(latitude: f32, longitude: f32) -> Result<Self, String>
Create a new GeoLocation
.
§Errors
Returns Err(String)
if either latitude
or longitude
is not a valid floating-point
number, or when they together do not represent a valid geo-location position.
§Error Examples
assert_eq!(
Err("Infinity is not a supported value for longitude".into()),
GeoLocation::new(23.456, std::f32::NEG_INFINITY)
);
assert_eq!(
Err("invalid latitude: 123.456 (must be between -90 and 90)".into()),
GeoLocation::new(123.456, 987.654)
);
§Examples
let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(12.345, geo.latitude());
assert_eq!(-98.765, geo.longitude());
Trait Implementations§
Source§impl Clone for GeoLocation
impl Clone for GeoLocation
Source§fn clone(&self) -> GeoLocation
fn clone(&self) -> GeoLocation
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for GeoLocation
impl Debug for GeoLocation
Source§impl<'de> Deserialize<'de> for GeoLocation
impl<'de> Deserialize<'de> for GeoLocation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for GeoLocation
impl Display for GeoLocation
Source§impl Hash for GeoLocation
impl Hash for GeoLocation
Source§impl PartialEq for GeoLocation
impl PartialEq for GeoLocation
Source§impl Serialize for GeoLocation
impl Serialize for GeoLocation
impl Copy for GeoLocation
impl Eq for GeoLocation
impl StructuralPartialEq for GeoLocation
Auto Trait Implementations§
impl Freeze for GeoLocation
impl RefUnwindSafe for GeoLocation
impl Send for GeoLocation
impl Sync for GeoLocation
impl Unpin for GeoLocation
impl UnwindSafe for GeoLocation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.