I have two different kinds of floats, Latitude and Longitude. How can I create nominal types for these different floats such that assigning a f32 variable with a semantic meaning of Longitude to a variable with a type and semantic meaning of Latitude is an error? Can I do this without a struct wrappering the primitive type?
type Longitude = f32;
type Latitude = f32;
fn main() {
let lng : Longitude = 42.0;
let lat : Latitude = lng; // <-- goal is a type error
println!("lat={}, lng={}", lat, lng);
}
How can I create nominal types for Rust primitives?