Struct decorum::ConstrainedFloat
source · #[repr(transparent)]pub struct ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,{ /* private fields */ }
Expand description
Floating-point proxy that provides ordering, hashing, and value constraints.
Wraps floating-point values and provides a proxy that implements operation
and numerical traits, including Hash
, Ord
, and Eq
. May apply
constraints that prevent certain values from occurring (by panicing).
Proxies canonicalize NaN
and zero to the forms CNaN
and C0
for the
following total ordering: [-INF | ... | C0 | ... | INF | CNaN ]
.
This type is re-exported but should not (and cannot) be used directly. Use
the exported type aliases instead (Ordered
, NotNan
, and Finite
).
Implementations
sourceimpl<T, P> ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcepub fn from_inner(value: T) -> Self
pub fn from_inner(value: T) -> Self
Converts a primitive floating-point value into a proxy.
This kind of conversion is the primary way to obtain a proxy. The same
behavior is provided by an implemention of the From
trait.
Panics
This conversion and the implementation of the From
trait will panic
if the primitive floating-point value violates the constraints of the
proxy.
Examples
Converting primitive floating-point values into proxies:
use decorum::R64;
fn f(x: R64) -> R64 {
x * 2.0
}
// Conversion using `from_inner`.
let y = f(R64::from_inner(2.0));
// Conversion using `From`/`Into`.
let z = f(2.0.into());
Performing a conversion that panics:
use decorum::R64;
// `R64` does not allow `NaN`s, but `0.0 / 0.0` produces a `NaN`.
let x = R64::from_inner(0.0 / 0.0); // Panics.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Converts a proxy into a primitive floating-point value.
Examples
Converting a proxy into a primitive floating-point value:
use decorum::R64;
fn f() -> R64 {
// ...
}
let x: f64 = f().into_inner();
sourcepub fn from_subset<Q>(other: ConstrainedFloat<T, Q>) -> Selfwhere
Q: FloatConstraint<T> + SubsetOf<P>,
pub fn from_subset<Q>(other: ConstrainedFloat<T, Q>) -> Selfwhere
Q: FloatConstraint<T> + SubsetOf<P>,
Converts a proxy into another proxy that is capable of representing a superset of values.
Examples
Converting between compatible proxy types:
use decorum::{N64, R64};
use num::Zero;
let x = R64::zero();
let y = N64::from_subset(x);
sourcepub fn into_superset<Q>(self) -> ConstrainedFloat<T, Q>where
Q: FloatConstraint<T> + SupersetOf<P>,
pub fn into_superset<Q>(self) -> ConstrainedFloat<T, Q>where
Q: FloatConstraint<T> + SupersetOf<P>,
Converts a proxy into another proxy that is capable of representing a superset of values.
Examples
Converting between compatible proxy types:
use decorum::{N64, R64};
use num::Zero;
let x = R64::zero();
let y: N64 = x.into_superset();
Trait Implementations
sourceimpl<T, P> Add<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Add<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Add<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Add<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> AddAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> AddAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresourceimpl<T, P> AddAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> AddAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read moresourceimpl<T, P> AsRef<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> AsRef<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Bounded for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Bounded for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T: Clone, P: Clone> Clone for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T: Clone, P: Clone> Clone for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn clone(&self) -> ConstrainedFloat<T, P>
fn clone(&self) -> ConstrainedFloat<T, P>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<T: Debug, P: Debug> Debug for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T: Debug, P: Debug> Debug for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Default for ConstrainedFloat<T, P>where
T: Default + Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Default for ConstrainedFloat<T, P>where
T: Default + Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<'de, T, P> Deserialize<'de> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
T: Deserialize<'de>,
impl<'de, T, P> Deserialize<'de> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl<T, P> Display for ConstrainedFloat<T, P>where
T: Display + Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Display for ConstrainedFloat<T, P>where
T: Display + Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Div<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Div<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Div<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Div<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> DivAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> DivAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
/=
operation. Read moresourceimpl<T, P> DivAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> DivAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/=
operation. Read moresourceimpl<T, P> Encoding for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Encoding for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Float for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintInfinity<T> + ConstraintNan<T> + ConstraintPartialOrd<T>,
impl<T, P> Float for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintInfinity<T> + ConstraintNan<T> + ConstraintPartialOrd<T>,
sourcefn neg_infinity() -> Self
fn neg_infinity() -> Self
sourcefn is_infinite(self) -> bool
fn is_infinite(self) -> bool
true
if this value is positive infinity or negative infinity and
false otherwise. Read moresourcefn max_value() -> Self
fn max_value() -> Self
sourcefn min_value() -> Self
fn min_value() -> Self
sourcefn min_positive_value() -> Self
fn min_positive_value() -> Self
sourcefn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true
if self
is positive, including +0.0
,
Float::infinity()
, and since Rust 1.20 also Float::nan()
. Read moresourcefn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true
if self
is negative, including -0.0
,
Float::neg_infinity()
, and since Rust 1.20 also -Float::nan()
. Read moresourcefn classify(self) -> FpCategory
fn classify(self) -> FpCategory
sourcefn integer_decode(self) -> (u64, i16, i8)
fn integer_decode(self) -> (u64, i16, i8)
sign * mantissa * 2 ^ exponent
. Read moresourcefn ceil(self) -> Self
fn ceil(self) -> Self
sourcefn round(self) -> Self
fn round(self) -> Self
0.0
. Read moresourcefn mul_add(self, a: Self, b: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
(self * a) + b
with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moresourcefn exp_m1(self) -> Self
fn exp_m1(self) -> Self
e^(self) - 1
in a way that is accurate even if the
number is close to zero. Read moresourcefn log(self, base: Self) -> Self
fn log(self, base: Self) -> Self
sourcefn ln_1p(self) -> Self
fn ln_1p(self) -> Self
ln(1+n)
(natural logarithm) more accurately than if
the operations were performed separately. Read moresourcefn hypot(self, other: Self) -> Self
fn hypot(self, other: Self) -> Self
x
and y
. Read moresourcefn asin(self) -> Self
fn asin(self) -> Self
sourcefn acos(self) -> Self
fn acos(self) -> Self
sourcefn atan(self) -> Self
fn atan(self) -> Self
sourcefn sin_cos(self) -> (Self, Self)
fn sin_cos(self) -> (Self, Self)
sourcefn to_degrees(self) -> Self
fn to_degrees(self) -> Self
sourcefn to_radians(self) -> Self
fn to_radians(self) -> Self
sourceimpl<T, P> FloatConst for ConstrainedFloat<T, P>where
T: Float + FloatConst + Primitive,
P: FloatConstraint<T>,
impl<T, P> FloatConst for ConstrainedFloat<T, P>where
T: Float + FloatConst + Primitive,
P: FloatConstraint<T>,
sourcefn FRAC_1_SQRT_2() -> Self
fn FRAC_1_SQRT_2() -> Self
1.0 / sqrt(2.0)
.sourcefn FRAC_2_SQRT_PI() -> Self
fn FRAC_2_SQRT_PI() -> Self
2.0 / sqrt(π)
.sourceimpl<T> From<ConstrainedFloat<T, FiniteConstraint<T>>> for NotNan<T>where
T: Float + Primitive,
impl<T> From<ConstrainedFloat<T, FiniteConstraint<T>>> for NotNan<T>where
T: Float + Primitive,
sourceimpl<T> From<ConstrainedFloat<T, FiniteConstraint<T>>> for Ordered<T>where
T: Float + Primitive,
impl<T> From<ConstrainedFloat<T, FiniteConstraint<T>>> for Ordered<T>where
T: Float + Primitive,
sourceimpl<T> From<ConstrainedFloat<T, NotNanConstraint<T>>> for Ordered<T>where
T: Float + Primitive,
impl<T> From<ConstrainedFloat<T, NotNanConstraint<T>>> for Ordered<T>where
T: Float + Primitive,
sourceimpl<P> From<ConstrainedFloat<f32, P>> for f32where
P: FloatConstraint<f32>,
impl<P> From<ConstrainedFloat<f32, P>> for f32where
P: FloatConstraint<f32>,
sourcefn from(value: ConstrainedFloat<f32, P>) -> Self
fn from(value: ConstrainedFloat<f32, P>) -> Self
sourceimpl<P> From<ConstrainedFloat<f64, P>> for f64where
P: FloatConstraint<f64>,
impl<P> From<ConstrainedFloat<f64, P>> for f64where
P: FloatConstraint<f64>,
sourcefn from(value: ConstrainedFloat<f64, P>) -> Self
fn from(value: ConstrainedFloat<f64, P>) -> Self
sourceimpl<T, P> From<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> From<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> FromPrimitive for ConstrainedFloat<T, P>where
T: Float + FromPrimitive + Primitive,
P: FloatConstraint<T>,
impl<T, P> FromPrimitive for ConstrainedFloat<T, P>where
T: Float + FromPrimitive + Primitive,
P: FloatConstraint<T>,
sourcefn from_i8(value: i8) -> Option<Self>
fn from_i8(value: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_u8(value: u8) -> Option<Self>
fn from_u8(value: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_i16(value: i16) -> Option<Self>
fn from_i16(value: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_u16(value: u16) -> Option<Self>
fn from_u16(value: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_i32(value: i32) -> Option<Self>
fn from_i32(value: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_u32(value: u32) -> Option<Self>
fn from_u32(value: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_i64(value: i64) -> Option<Self>
fn from_i64(value: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_u64(value: u64) -> Option<Self>
fn from_u64(value: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_isize(value: isize) -> Option<Self>
fn from_isize(value: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_usize(value: usize) -> Option<Self>
fn from_usize(value: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_f32(value: f32) -> Option<Self>
fn from_f32(value: f32) -> Option<Self>
f32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourcefn from_f64(value: f64) -> Option<Self>
fn from_f64(value: f64) -> Option<Self>
f64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresourceimpl<T, P> FromStr for ConstrainedFloat<T, P>where
T: Float + FromStr + Primitive,
P: FloatConstraint<T>,
impl<T, P> FromStr for ConstrainedFloat<T, P>where
T: Float + FromStr + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Hash for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Hash for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Infinite for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintInfinity<T>,
impl<T, P> Infinite for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintInfinity<T>,
fn infinity() -> Self
fn neg_infinity() -> Self
fn is_infinite(self) -> bool
fn is_finite(self) -> bool
sourceimpl<T, P> LowerExp for ConstrainedFloat<T, P>where
T: Float + LowerExp + Primitive,
P: FloatConstraint<T>,
impl<T, P> LowerExp for ConstrainedFloat<T, P>where
T: Float + LowerExp + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Mul<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Mul<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Mul<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Mul<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> MulAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> MulAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
*=
operation. Read moresourceimpl<T, P> MulAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> MulAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*=
operation. Read moresourceimpl<T, P> Nan for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T> + ConstraintNan<T>,
impl<T, P> Nan for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T> + ConstraintNan<T>,
sourceimpl<T, P> Neg for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T>,
impl<T, P> Neg for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Num for ConstrainedFloat<T, P>where
Self: PartialEq,
T: Float + Num + Primitive,
P: FloatConstraint<T>,
impl<T, P> Num for ConstrainedFloat<T, P>where
Self: PartialEq,
T: Float + Num + Primitive,
P: FloatConstraint<T>,
type FromStrRadixErr = ()
sourcefn from_str_radix(
source: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(
source: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresourceimpl<T, P> NumCast for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T>,
impl<T, P> NumCast for ConstrainedFloat<T, P>where
T: Float + Num + Primitive,
P: FloatConstraint<T>,
sourcefn from<U>(value: U) -> Option<Self>where
U: ToPrimitive,
fn from<U>(value: U) -> Option<Self>where
U: ToPrimitive,
ToPrimitive
trait. If the source value cannot be
represented by the target type, then None
is returned. Read moresourceimpl<T, P> One for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> One for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Ord for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintOrd<T>,
impl<T, P> Ord for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintOrd<T>,
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<T, P> PartialEq<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T>,
impl<T, P> PartialEq<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T>,
sourceimpl<T, P> PartialEq<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T>,
impl<T, P> PartialEq<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T>,
sourceimpl<T, P> PartialOrd<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
impl<T, P> PartialOrd<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl<T, P> PartialOrd<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
impl<T, P> PartialOrd<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
sourcefn partial_cmp(&self, other: &T) -> Option<Ordering>
fn partial_cmp(&self, other: &T) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl<T, P> Product<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Product<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Real for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
impl<T, P> Real for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T> + ConstraintPartialOrd<T>,
fn min(self, other: Self) -> Self
fn max(self, other: Self) -> Self
fn is_sign_positive(self) -> bool
fn is_sign_negative(self) -> bool
fn signum(self) -> Self
fn abs(self) -> Self
fn floor(self) -> Self
fn ceil(self) -> Self
fn round(self) -> Self
fn trunc(self) -> Self
fn fract(self) -> Self
fn recip(self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
fn abs_sub(self, other: Self) -> Self
fn powi(self, n: i32) -> Self
fn powf(self, n: Self) -> Self
fn sqrt(self) -> Self
fn cbrt(self) -> Self
fn exp(self) -> Self
fn exp2(self) -> Self
fn exp_m1(self) -> Self
fn log(self, base: Self) -> Self
fn ln(self) -> Self
fn log2(self) -> Self
fn log10(self) -> Self
fn ln_1p(self) -> Self
fn hypot(self, other: Self) -> Self
fn sin(self) -> Self
fn cos(self) -> Self
fn tan(self) -> Self
fn asin(self) -> Self
fn acos(self) -> Self
fn atan(self) -> Self
fn atan2(self, other: Self) -> Self
fn sin_cos(self) -> (Self, Self)
fn sinh(self) -> Self
fn cosh(self) -> Self
fn tanh(self) -> Self
fn asinh(self) -> Self
fn acosh(self) -> Self
fn atanh(self) -> Self
sourceimpl<T, P> Rem<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Rem<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Rem<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Rem<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> RemAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> RemAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn rem_assign(&mut self, other: Self)
fn rem_assign(&mut self, other: Self)
%=
operation. Read moresourceimpl<T, P> RemAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> RemAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
%=
operation. Read moresourceimpl<T, P> Serialize for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
T: Serialize,
impl<T, P> Serialize for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
T: Serialize,
sourceimpl<T, P> Signed for ConstrainedFloat<T, P>where
T: Float + Primitive + Signed,
P: FloatConstraint<T> + ConstraintEq<T>,
impl<T, P> Signed for ConstrainedFloat<T, P>where
T: Float + Primitive + Signed,
P: FloatConstraint<T> + ConstraintEq<T>,
sourcefn is_positive(&self) -> bool
fn is_positive(&self) -> bool
sourcefn is_negative(&self) -> bool
fn is_negative(&self) -> bool
sourceimpl<T, P> Sub<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Sub<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Sub<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Sub<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> SubAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> SubAssign<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read moresourceimpl<T, P> SubAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> SubAssign<T> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourcefn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moresourceimpl<T, P> Sum<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Sum<ConstrainedFloat<T, P>> for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> ToPrimitive for ConstrainedFloat<T, P>where
T: Float + Primitive + ToPrimitive,
P: FloatConstraint<T>,
impl<T, P> ToPrimitive for ConstrainedFloat<T, P>where
T: Float + Primitive + ToPrimitive,
P: FloatConstraint<T>,
sourcefn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned. Read moresourcefn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned. Read moresourcefn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned. Read moresourcefn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned. Read moresourcefn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned. Read moresourcefn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned. Read moresourcefn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned. Read moresourcefn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned. Read moresourcefn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned. Read moresourcefn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned. Read moresourcefn to_f32(&self) -> Option<f32>
fn to_f32(&self) -> Option<f32>
self
to an f32
. Overflows may map to positive
or negative inifinity, otherwise None
is returned if the value cannot
be represented by an f32
. Read moresourcefn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
self
to an f64
. Overflows may map to positive
or negative inifinity, otherwise None
is returned if the value cannot
be represented by an f64
. Read moresourceimpl<T, P> UpperExp for ConstrainedFloat<T, P>where
T: Float + UpperExp + Primitive,
P: FloatConstraint<T>,
impl<T, P> UpperExp for ConstrainedFloat<T, P>where
T: Float + UpperExp + Primitive,
P: FloatConstraint<T>,
sourceimpl<T, P> Zero for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Zero for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T: Copy, P: Copy> Copy for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T>,
impl<T, P> Eq for ConstrainedFloat<T, P>where
T: Float + Primitive,
P: FloatConstraint<T> + ConstraintEq<T>,
Auto Trait Implementations
impl<T, P> RefUnwindSafe for ConstrainedFloat<T, P>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for ConstrainedFloat<T, P>where
P: Send,
T: Send,
impl<T, P> Sync for ConstrainedFloat<T, P>where
P: Sync,
T: Sync,
impl<T, P> Unpin for ConstrainedFloat<T, P>where
P: Unpin,
T: Unpin,
impl<T, P> UnwindSafe for ConstrainedFloat<T, P>where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> LowerBounded for Twhere
T: Bounded,
impl<T> LowerBounded for Twhere
T: Bounded,
sourceimpl<T> Real for Twhere
T: Float,
impl<T> Real for Twhere
T: Float,
sourcefn min_positive_value() -> T
fn min_positive_value() -> T
sourcefn round(self) -> T
fn round(self) -> T
0.0
. Read moresourcefn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true
if self
is positive, including +0.0
,
Float::infinity()
, and with newer versions of Rust f64::NAN
. Read moresourcefn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true
if self
is negative, including -0.0
,
Float::neg_infinity()
, and with newer versions of Rust -f64::NAN
. Read moresourcefn mul_add(self, a: T, b: T) -> T
fn mul_add(self, a: T, b: T) -> T
(self * a) + b
with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moresourcefn log(self, base: T) -> T
fn log(self, base: T) -> T
sourcefn to_degrees(self) -> T
fn to_degrees(self) -> T
sourcefn to_radians(self) -> T
fn to_radians(self) -> T
sourcefn hypot(self, other: T) -> T
fn hypot(self, other: T) -> T
x
and y
. Read moresourcefn asin(self) -> T
fn asin(self) -> T
sourcefn acos(self) -> T
fn acos(self) -> T
sourcefn atan(self) -> T
fn atan(self) -> T
sourcefn exp_m1(self) -> T
fn exp_m1(self) -> T
e^(self) - 1
in a way that is accurate even if the
number is close to zero. Read more