Skip to main content

Value

Trait Value 

Source
pub trait Value:
    Scalar
    + ComplexField<RealField = Self>
    + RealField
    + FloatCore
    + LowerExp {
Show 20 methods // Provided methods fn two() -> Self { ... } fn half() -> Self { ... } fn try_cast<U: NumCast>(n: U) -> Result<Self, Error> { ... } fn as_usize(&self) -> Option<usize> { ... } fn powi(self, n: i32) -> Self { ... } fn abs(self) -> Self { ... } fn abs_sub(self, other: Self) -> Self { ... } fn is_sign_negative(&self) -> bool { ... } fn clamp(self, min: Self, max: Self) -> Self { ... } fn min(self, other: Self) -> Self { ... } fn max(self, other: Self) -> Self { ... } fn ceil(self) -> Self { ... } fn floor(self) -> Self { ... } fn is_near_zero(&self) -> bool { ... } fn is_finite(value: Self) -> bool { ... } fn f_signum(&self) -> Self { ... } fn factorial(n: usize) -> Self { ... } fn integer_binomial(n: usize, k: usize) -> Self { ... } fn binomial(n: Self, k: Self) -> Self { ... } fn from_positive_int(n: usize) -> Self { ... }
}
Expand description

Numeric type for curves

Provided Methods§

Source

fn two() -> Self

Returns the value 2.0

Source

fn half() -> Self

Returns the value 0.5

Source

fn try_cast<U: NumCast>(n: U) -> Result<Self, Error>

Tries to cast a value to the target type

§Errors

Returns an error if the cast fails

Source

fn as_usize(&self) -> Option<usize>

Converts the value to usize

Source

fn powi(self, n: i32) -> Self

Raises the value to the power of an integer

Source

fn abs(self) -> Self

Get the absolute value for a numeric type

Source

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

Returns the absolute difference between two values.

Source

fn is_sign_negative(&self) -> bool

Check if the value is negative

Source

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

Clamps the value between a minimum and maximum.

Source

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

Returns the minimum of two values.

Source

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

Returns the maximum of two values.

Source

fn ceil(self) -> Self

Return the next value greater than self

Source

fn floor(self) -> Self

Return the next value less than self

Source

fn is_near_zero(&self) -> bool

Returns the machine epsilon for the numeric type.

Source

fn is_finite(value: Self) -> bool

Checks if the value is finite (not NaN or infinite).

Source

fn f_signum(&self) -> Self

Returns the sign of the value as a numeric type

This function returns -1 for negative values, 1 for positive values, and NaN for NaN values.

Source

fn factorial(n: usize) -> Self

Computes the factorial of a non-negative integer n.

Source

fn integer_binomial(n: usize, k: usize) -> Self

Computes the binomial coefficient “n choose k” for integer n and k.

Source

fn binomial(n: Self, k: Self) -> Self

Computes the binomial coefficient “n choose k”.

Source

fn from_positive_int(n: usize) -> Self

Converts a usize to the target numeric type.

Results in infinity if the value is out of range.

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<T> Value for T
where T: Scalar + ComplexField<RealField = Self> + RealField + FloatCore + LowerExp,