#[repr(C)]pub enum Cardinal {
East = 0,
South = 1,
West = 2,
North = 3,
}Expand description
A cardinal (4-way) direction.
Variants§
Implementations§
Source§impl Cardinal
impl Cardinal
Sourcepub fn from_index(idx: usize) -> Option<Self>
pub fn from_index(idx: usize) -> Option<Self>
Parse from a direction’s variant index.
Source§impl Cardinal
impl Cardinal
Sourcepub fn from_octal(oct: Octal, bias: Self) -> Self
pub fn from_octal(oct: Octal, bias: Self) -> Self
Given an octal direction, return the cardinal direction that most closely represents it. This is effectively snapping the angle to 90°.
The bias provides a direction to be used as a tiebreaker; when an octal
direction is equidistant between two cardinal direction (eg. NorthEast
is equally close to North and East), the direction nearest to the bias
will be chosen.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cardinal
impl<'de> Deserialize<'de> for Cardinal
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<T: Float> Direction<T> for Cardinal
impl<T: Float> Direction<T> for Cardinal
Source§fn to_degrees(self) -> Degrees<T>
fn to_degrees(self) -> Degrees<T>
Angle of the direction in degrees.
Source§fn to_radians(self) -> Radians<T>
fn to_radians(self) -> Radians<T>
Angle of the direction in radians.
Source§fn to_rotations(self) -> Rotations<T>
fn to_rotations(self) -> Rotations<T>
Angle of the direction in rotations.
Source§impl Ord for Cardinal
impl Ord for Cardinal
Source§impl PartialOrd for Cardinal
impl PartialOrd for Cardinal
impl Copy for Cardinal
impl Eq for Cardinal
impl StructuralPartialEq for Cardinal
Auto Trait Implementations§
impl Freeze for Cardinal
impl RefUnwindSafe for Cardinal
impl Send for Cardinal
impl Sync for Cardinal
impl Unpin for Cardinal
impl UnwindSafe for Cardinal
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