#[non_exhaustive]pub enum CardinalPoint {
N,
NE,
E,
SE,
S,
SW,
W,
NW,
}Expand description
Cardinal or intercardinal compass point.
A type rather than a string, so deviation-table points cannot be misspelled:
a typo is a compile error, or KernelError::UnknownCardinalDirection when
parsed, never a silent failed lookup.
#[non_exhaustive]; match with a wildcard arm.
§Example
use kinavis_kernel::{CardinalPoint, CompassCourse};
assert_eq!(CardinalPoint::SW.degrees(), 225.0);
assert_eq!("sw".parse::<CardinalPoint>()?, CardinalPoint::SW);
assert_eq!(CompassCourse::from(CardinalPoint::SW).degrees(), 225.0);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
N
North, 000°.
NE
North-east, 045°.
E
East, 090°.
SE
South-east, 135°.
S
South, 180°.
SW
South-west, 225°.
W
West, 270°.
NW
North-west, 315°.
Implementations§
Source§impl CardinalPoint
impl CardinalPoint
Sourcepub const fn whole_degrees(self) -> i32
pub const fn whole_degrees(self) -> i32
Course of the point in whole degrees, 0..360.
The points fall on multiples of 45°, and deviation tables are indexed by whole degrees.
Sourcepub const fn abbreviation(self) -> &'static str
pub const fn abbreviation(self) -> &'static str
Abbreviation, "N" to "NW".
Trait Implementations§
Source§impl Clone for CardinalPoint
impl Clone for CardinalPoint
impl Copy for CardinalPoint
Source§impl Debug for CardinalPoint
impl Debug for CardinalPoint
Source§impl Default for CardinalPoint
impl Default for CardinalPoint
Source§impl Display for CardinalPoint
impl Display for CardinalPoint
impl Eq for CardinalPoint
Source§impl<F: Frame> From<CardinalPoint> for Direction<F>
impl<F: Frame> From<CardinalPoint> for Direction<F>
Source§fn from(point: CardinalPoint) -> Self
fn from(point: CardinalPoint) -> Self
The point as a direction in any frame; the point itself has no frame.
Source§impl FromStr for CardinalPoint
impl FromStr for CardinalPoint
Source§impl Hash for CardinalPoint
impl Hash for CardinalPoint
Source§impl Ord for CardinalPoint
impl Ord for CardinalPoint
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for CardinalPoint
impl PartialEq for CardinalPoint
Source§impl PartialOrd for CardinalPoint
impl PartialOrd for CardinalPoint
impl StructuralPartialEq for CardinalPoint
Auto Trait Implementations§
impl Freeze for CardinalPoint
impl RefUnwindSafe for CardinalPoint
impl Send for CardinalPoint
impl Sync for CardinalPoint
impl Unpin for CardinalPoint
impl UnsafeUnpin for CardinalPoint
impl UnwindSafe for CardinalPoint
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