Skip to main content

lat

Macro lat 

Source
macro_rules! lat {
    (N $degrees:expr, $minutes:expr, $seconds:expr) => { ... };
    (S $degrees:expr, $minutes:expr, $seconds:expr) => { ... };
    ($degrees:expr, $minutes:expr, $seconds:expr) => { ... };
    (N $degrees:expr, $minutes:expr) => { ... };
    (S $degrees:expr, $minutes:expr) => { ... };
    ($degrees:expr, $minutes:expr) => { ... };
    (N $degrees:expr) => { ... };
    (S $degrees:expr) => { ... };
    ($degrees:expr) => { ... };
}
Expand description

Ergonomic constructor for Latitude values.

All forms .unwrap() internally — they are intended for compile-time-known constants and tests where invalid input is a bug. Use Latitude::new when you need to handle validation errors.

FormExampleMeaning
lat!(d)lat!(45)45° N
lat!(d, m)lat!(45, 30)45° 30′ N
lat!(d, m, s)lat!(45, 30, 0.0)45° 30′ 0″ N
lat!(N d, …) / lat!(S d, …)lat!(S 33, 51, 24.0)explicit hemisphere

The N/S prefix forms take the absolute value of the degree argument and apply the sign matching the direction.

§Examples

use lat_long::{Angle, Latitude, lat};

let lat = lat!(45, 30, 0.0);
assert!(lat.is_northern());
assert_eq!(lat.degrees(), 45);