Skip to main content

Angle

Trait Angle 

Source
pub trait Angle:
    Clone
    + Copy
    + Debug
    + Default
    + Display
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Hash
    + TryFrom<OrderedFloat<f64>, Error = Error>
    + Into<OrderedFloat<f64>> {
    const MIN: Self;
    const MAX: Self;
Show 14 methods // Required method fn new(degrees: i32, minutes: u32, seconds: f32) -> Result<Self, Error> where Self: Sized; // Provided methods fn as_float(&self) -> OrderedFloat<f64> { ... } fn is_zero(&self) -> bool { ... } fn is_nonzero_positive(&self) -> bool { ... } fn is_nonzero_negative(&self) -> bool { ... } fn degrees(&self) -> i32 { ... } fn minutes(&self) -> u32 { ... } fn seconds(&self) -> f32 { ... } fn checked_abs(self) -> Option<Self> where Self: Sized { ... } fn overflowing_abs(self) -> (Self, bool) where Self: Sized { ... } fn saturating_abs(self) -> Self where Self: Sized { ... } fn strict_abs(self) -> Self where Self: Sized { ... } fn unchecked_abs(self) -> Self where Self: Sized { ... } fn wrapping_abs(self) -> Self where Self: Sized { ... }
}

Required Associated Constants§

Source

const MIN: Self

Source

const MAX: Self

Required Methods§

Source

fn new(degrees: i32, minutes: u32, seconds: f32) -> Result<Self, Error>
where Self: Sized,

Construct a new angle from degrees, minutes, and seconds.

Provided Methods§

Source

fn as_float(&self) -> OrderedFloat<f64>

Source

fn is_zero(&self) -> bool

Returns true if the angle is exactly zero.

Source

fn is_nonzero_positive(&self) -> bool

Returns true if the angle is positive and non-zero.

Source

fn is_nonzero_negative(&self) -> bool

Returns true if the angle is negative and non-zero.

Source

fn degrees(&self) -> i32

The signed integer degrees component (carries the sign for negative angles).

Source

fn minutes(&self) -> u32

The unsigned minutes component (always in 0..60).

Source

fn seconds(&self) -> f32

The unsigned seconds component (always in 0.0..60.0).

Source

fn checked_abs(self) -> Option<Self>
where Self: Sized,

Checked absolute value. Computes self.abs(), returning None if self == MIN.

Source

fn overflowing_abs(self) -> (Self, bool)
where Self: Sized,

Computes the absolute value of self.

Returns a tuple of the absolute version of self along with a boolean indicating whether an overflow happened. If self is the minimum value Self::MIN, then the minimum value will be returned again and true will be returned for an overflow happening.

Source

fn saturating_abs(self) -> Self
where Self: Sized,

Saturating absolute value. Computes self.abs(), returning MAX if self == MIN instead of overflowing.

Source

fn strict_abs(self) -> Self
where Self: Sized,

Strict absolute value. Computes self.abs(), panicking if self == MIN.

Source

fn unchecked_abs(self) -> Self
where Self: Sized,

Unchecked absolute value. Computes self.abs(), assuming overflow cannot occur.

Calling x.unchecked_abs() is semantically equivalent to calling x.checked_abs().unwrap_unchecked().

If you’re just trying to avoid the panic in debug mode, then do not use this. Instead, you’re looking for wrapping_abs.

Source

fn wrapping_abs(self) -> Self
where Self: Sized,

Wrapping (modular) absolute value. Computes self.abs(), wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one takes the absolute value of the negative minimal value for the type; this is a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Angle for Latitude

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Angle for Longitude

Source§

const MIN: Self

Source§

const MAX: Self