33 lines
731 B
Rust
33 lines
731 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
/// Geographic coordinates (longitude and latitude)
|
|
///
|
|
/// # Example
|
|
/// ```
|
|
/// use owm_api25::current::Coord;
|
|
///
|
|
/// let coord = Coord { lon: -0.1257, lat: 51.5085 };
|
|
/// assert_eq!(coord.lon, -0.1257);
|
|
/// assert_eq!(coord.lat, 51.5085);
|
|
/// ```
|
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
|
pub struct Coord {
|
|
pub lon: f64,
|
|
pub lat: f64,
|
|
}
|
|
|
|
impl Coord {
|
|
/// Creates new coordinates from longitude and latitude
|
|
///
|
|
/// # Example
|
|
/// ```
|
|
/// use owm_api25::current::Coord;
|
|
///
|
|
/// let london = Coord::new(-0.1257, 51.5085);
|
|
/// ```
|
|
#[must_use]
|
|
pub fn new(lon: f64, lat: f64) -> Self {
|
|
Self { lon, lat }
|
|
}
|
|
}
|