[]Struct gdnative::common::euclid::Length

#[repr(C)]
pub struct Length<T, Unit>(pub T, _);

A one-dimensional distance, with value represented by T and unit of measurement Unit.

T can be any numeric type, for example a primitive type like u64 or f32.

Unit is not used in the representation of a Length value. It is used only at compile time to ensure that a Length stored with one unit is converted explicitly before being used in an expression that requires a different unit. It may be a type without values, such as an empty enum.

You can multiply a Length by a scale::TypedScale to convert it from one unit to another. See the TypedScale docs for an example.

Methods

impl<T, Unit> Length<T, Unit>

pub fn new(x: T) -> Length<T, Unit>

impl<Unit, T> Length<T, Unit> where
    T: Clone

pub fn get(&self) -> T

impl<Unit, T0> Length<T0, Unit> where
    T0: Clone + NumCast

pub fn cast<T1>(&self) -> Length<T1, Unit> where
    T1: Clone + NumCast

Cast from one numeric representation to another, preserving the units.

pub fn try_cast<T1>(&self) -> Option<Length<T1, Unit>> where
    T1: Clone + NumCast

Fallible cast from one numeric representation to another, preserving the units.

impl<T, U> Length<T, U> where
    T: One + Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Copy

pub fn lerp(&self, other: Length<T, U>, t: T) -> Length<T, U>

Linearly interpolate between this length and another length.

t is expected to be between zero and one.

Trait Implementations

impl<U, T> SubAssign<Length<T, U>> for Length<T, U> where
    T: SubAssign<T> + Clone

impl<T, U> MulAssign<T> for Length<T, U> where
    T: Copy + Mul<T, Output = T>, 

impl<U, T> Sub<Length<T, U>> for Length<T, U> where
    T: Sub<T, Output = T> + Clone

type Output = Length<T, U>

The resulting type after applying the - operator.

impl<Unit, T> PartialEq<Length<T, Unit>> for Length<T, Unit> where
    T: PartialEq<T> + Clone

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<Unit, T> Eq for Length<T, Unit> where
    T: Eq + Clone

impl<T, U> Display for Length<T, U> where
    T: Clone + Display

impl<Unit, T> Ord for Length<T, Unit> where
    T: Ord + Clone

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl<U, T> Add<Length<T, U>> for Length<T, U> where
    T: Add<T, Output = T> + Clone

type Output = Length<T, U>

The resulting type after applying the + operator.

impl<T, Unit> Clone for Length<T, Unit> where
    T: Clone

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T, U> Debug for Length<T, U> where
    T: Clone + Debug

impl<Src, Dst, T> Div<TypedScale<T, Src, Dst>> for Length<T, Dst> where
    T: Div<T, Output = T> + Clone

type Output = Length<T, Src>

The resulting type after applying the / operator.

impl<Src, Dst, T> Div<Length<T, Src>> for Length<T, Dst> where
    T: Div<T, Output = T> + Clone

type Output = TypedScale<T, Src, Dst>

The resulting type after applying the / operator.

impl<T, U> Div<T> for Length<T, U> where
    T: Copy + Div<T, Output = T>, 

type Output = Length<T, U>

The resulting type after applying the / operator.

impl<U, T> AddAssign<Length<T, U>> for Length<T, U> where
    T: AddAssign<T> + Clone

impl<T, Unit> Copy for Length<T, Unit> where
    T: Copy

impl<U, T> Saturating for Length<T, U> where
    T: Clone + Saturating

impl<Unit, T> PartialOrd<Length<T, Unit>> for Length<T, Unit> where
    T: PartialOrd<T> + Clone

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<U, T> Neg for Length<T, U> where
    T: Neg<Output = T> + Clone

type Output = Length<T, U>

The resulting type after applying the - operator.

impl<Unit, T> Zero for Length<T, Unit> where
    T: Zero

impl<T, U> DivAssign<T> for Length<T, U> where
    T: Copy + Div<T, Output = T>, 

impl<T, U> Mul<T> for Length<T, U> where
    T: Copy + Mul<T, Output = T>, 

type Output = Length<T, U>

The resulting type after applying the * operator.

impl<Src, Dst, T> Mul<TypedScale<T, Src, Dst>> for Length<T, Src> where
    T: Mul<T, Output = T> + Clone

type Output = Length<T, Dst>

The resulting type after applying the * operator.

Auto Trait Implementations

impl<T, Unit> Send for Length<T, Unit> where
    T: Send,
    Unit: Send

impl<T, Unit> Sync for Length<T, Unit> where
    T: Sync,
    Unit: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Zero for T where
    T: Zero