Skip to main content

Scalar

Trait Scalar 

Source
pub trait Scalar:
    Copy
    + Clone
    + Send
    + Sync
    + 'static
    + Default
    + PartialOrd
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Rem<Output = Self>
    + Neg<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + Debug {
    const ZERO: Self;
    const ONE: Self;
    const MIN: Self;
    const MAX: Self;

    // Required methods
    fn abs(self) -> Self;
    fn min(self, other: Self) -> Self;
    fn max(self, other: Self) -> Self;
    fn clamp(self, min: Self, max: Self) -> Self;
}
Expand description

Базовый числовой трейт для любых скалярных типов.

Включает арифметику, min/max/clamp, abs. Реализован для f32, f64 и всех целых типов (i8/i16/i32/i64, u8/u16/u32/u64).

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const MIN: Self

Source

const MAX: Self

Required Methods§

Source

fn abs(self) -> Self

Source

fn min(self, other: Self) -> Self

Source

fn max(self, other: Self) -> Self

Source

fn clamp(self, min: Self, max: Self) -> Self

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.

Implementations on Foreign Types§

Source§

impl Scalar for f32

Source§

const ZERO: f32 = 0.0

Source§

const ONE: f32 = 1.0

Source§

const MIN: f32 = -1.0

Source§

const MAX: f32 = 1.0

Source§

fn abs(self) -> f32

Source§

fn min(self, other: f32) -> f32

Source§

fn max(self, other: f32) -> f32

Source§

fn clamp(self, min: f32, max: f32) -> f32

Source§

impl Scalar for f64

Source§

const ZERO: f64 = 0.0

Source§

const ONE: f64 = 1.0

Source§

const MIN: f64 = -1.0

Source§

const MAX: f64 = 1.0

Source§

fn abs(self) -> f64

Source§

fn min(self, other: f64) -> f64

Source§

fn max(self, other: f64) -> f64

Source§

fn clamp(self, min: f64, max: f64) -> f64

Source§

impl Scalar for i8

Source§

const ZERO: i8 = 0

Source§

const ONE: i8 = 1

Source§

const MIN: i8 = i8::MIN

Source§

const MAX: i8 = i8::MAX

Source§

fn abs(self) -> i8

Source§

fn min(self, other: i8) -> i8

Source§

fn max(self, other: i8) -> i8

Source§

fn clamp(self, lo: i8, hi: i8) -> i8

Source§

impl Scalar for i16

Source§

const ZERO: i16 = 0

Source§

const ONE: i16 = 1

Source§

const MIN: i16 = i16::MIN

Source§

const MAX: i16 = i16::MAX

Source§

fn abs(self) -> i16

Source§

fn min(self, other: i16) -> i16

Source§

fn max(self, other: i16) -> i16

Source§

fn clamp(self, lo: i16, hi: i16) -> i16

Source§

impl Scalar for i32

Source§

const ZERO: i32 = 0

Source§

const ONE: i32 = 1

Source§

const MIN: i32 = i32::MIN

Source§

const MAX: i32 = i32::MAX

Source§

fn abs(self) -> i32

Source§

fn min(self, other: i32) -> i32

Source§

fn max(self, other: i32) -> i32

Source§

fn clamp(self, lo: i32, hi: i32) -> i32

Source§

impl Scalar for i64

Source§

const ZERO: i64 = 0

Source§

const ONE: i64 = 1

Source§

const MIN: i64 = i64::MIN

Source§

const MAX: i64 = i64::MAX

Source§

fn abs(self) -> i64

Source§

fn min(self, other: i64) -> i64

Source§

fn max(self, other: i64) -> i64

Source§

fn clamp(self, lo: i64, hi: i64) -> i64

Implementors§