Trait cgmath::prelude::One

source ·
pub trait One: Sized + Mul<Self, Output = Self> {
    // Required method
    fn one() -> Self;

    // Provided methods
    fn set_one(&mut self) { ... }
    fn is_one(&self) -> bool
       where Self: PartialEq<Self> { ... }
}
Expand description

Defines a multiplicative identity element for Self.

Laws

a * 1 = a       ∀ a ∈ Self
1 * a = a       ∀ a ∈ Self

Required Methods§

source

fn one() -> Self

Returns the multiplicative identity element of Self, 1.

Purity

This function should return the same result at all times regardless of external mutable state, for example values stored in TLS or in static muts.

Provided Methods§

source

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.

source

fn is_one(&self) -> boolwhere Self: PartialEq<Self>,

Returns true if self is equal to the multiplicative identity.

For performance reasons, it’s best to implement this manually. After a semver bump, this method will be required, and the where Self: PartialEq bound will be removed.

Implementations on Foreign Types§

source§

impl One for i8

source§

fn one() -> i8

source§

fn is_one(&self) -> bool

source§

impl One for u32

source§

fn one() -> u32

source§

fn is_one(&self) -> bool

source§

impl One for u128

source§

fn one() -> u128

source§

fn is_one(&self) -> bool

source§

impl One for u16

source§

fn one() -> u16

source§

fn is_one(&self) -> bool

source§

impl One for f64

source§

fn one() -> f64

source§

fn is_one(&self) -> bool

source§

impl One for usize

source§

fn one() -> usize

source§

fn is_one(&self) -> bool

source§

impl One for u64

source§

fn one() -> u64

source§

fn is_one(&self) -> bool

source§

impl One for i32

source§

fn one() -> i32

source§

fn is_one(&self) -> bool

source§

impl One for i16

source§

fn one() -> i16

source§

fn is_one(&self) -> bool

source§

impl One for i128

source§

fn one() -> i128

source§

fn is_one(&self) -> bool

source§

impl One for i64

source§

fn one() -> i64

source§

fn is_one(&self) -> bool

source§

impl One for isize

source§

fn one() -> isize

source§

fn is_one(&self) -> bool

source§

impl One for u8

source§

fn one() -> u8

source§

fn is_one(&self) -> bool

source§

impl One for f32

source§

fn one() -> f32

source§

fn is_one(&self) -> bool

source§

impl<T> One for Wrapping<T>where T: One, Wrapping<T>: Mul<Wrapping<T>, Output = Wrapping<T>>,

source§

fn set_one(&mut self)

source§

fn one() -> Wrapping<T>

Implementors§

source§

impl<P: EuclideanSpace, R: Rotation<Space = P>> One for Decomposed<P::Diff, R>where P::Scalar: BaseFloat,

source§

impl<S: BaseFloat> One for Basis2<S>

source§

impl<S: BaseFloat> One for Basis3<S>

source§

impl<S: BaseFloat> One for Matrix2<S>

source§

impl<S: BaseFloat> One for Matrix3<S>

source§

impl<S: BaseFloat> One for Matrix4<S>

source§

impl<S: BaseFloat> One for Quaternion<S>