Struct decorum::ConstrainedFloat
[−]
[src]
pub struct ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>, { /* fields omitted */ }
Constrained, ordered, hashable floating point proxy.
Wraps floating point values and provides a proxy that implements operation
and numerical traits, including Hash
, Ord
, and Eq
.
Methods
impl<T, P> ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn try_from_raw_float(value: T) -> Result<Self, ()>
[src]
fn into_raw_float(self) -> T
[src]
impl<T, P> ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn from_raw_float(value: T) -> Self
[src]
Trait Implementations
impl<'a, T, P> Deserialize<'a> for ConstrainedFloat<T, P> where
T: Deserialize<'a> + Float,
P: FloatConstraint<T>,
[src]
T: Deserialize<'a> + Float,
P: FloatConstraint<T>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'a>,
[src]
D: Deserializer<'a>,
Deserialize this value from the given Serde deserializer. Read more
impl<T, P> Serialize for ConstrainedFloat<T, P> where
T: Float + Serialize,
P: FloatConstraint<T>,
[src]
T: Float + Serialize,
P: FloatConstraint<T>,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, P> Clone for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
T: Clone,
[src]
T: Float,
P: FloatConstraint<T>,
T: Clone,
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T, P> Copy for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
T: Copy,
[src]
T: Float,
P: FloatConstraint<T>,
T: Copy,
impl<T, P> Debug for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
T: Debug,
[src]
T: Float,
P: FloatConstraint<T>,
T: Debug,
impl<T, P> Default for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
T: Default,
[src]
T: Float,
P: FloatConstraint<T>,
T: Default,
impl<T, P> AsRef<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
impl<P> Into<f32> for ConstrainedFloat<f32, P> where
P: FloatConstraint<f32>,
[src]
P: FloatConstraint<f32>,
impl<P> Into<f64> for ConstrainedFloat<f64, P> where
P: FloatConstraint<f64>,
[src]
P: FloatConstraint<f64>,
impl<T, P> Add for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output
[src]
Performs the +
operation.
impl<T, P> Add<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: T) -> Self::Output
[src]
Performs the +
operation.
impl<T, P> AddAssign for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn add_assign(&mut self, other: Self)
[src]
Performs the +=
operation.
impl<T, P> AddAssign<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn add_assign(&mut self, other: T)
[src]
Performs the +=
operation.
impl<T, P> Bounded for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn min_value() -> Self
[src]
returns the smallest finite number this type can represent
fn max_value() -> Self
[src]
returns the largest finite number this type can represent
impl<T, P> Display for ConstrainedFloat<T, P> where
T: Display + Float,
P: FloatConstraint<T>,
[src]
T: Display + Float,
P: FloatConstraint<T>,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T, P> Div for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: Self) -> Self::Output
[src]
Performs the /
operation.
impl<T, P> Div<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: T) -> Self::Output
[src]
Performs the /
operation.
impl<T, P> DivAssign for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn div_assign(&mut self, other: Self)
[src]
Performs the /=
operation.
impl<T, P> DivAssign<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn div_assign(&mut self, other: T)
[src]
Performs the /=
operation.
impl<T, P> Eq for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
impl<T, P> FloatConst for ConstrainedFloat<T, P> where
T: Float + FloatConst,
P: FloatConstraint<T>,
[src]
T: Float + FloatConst,
P: FloatConstraint<T>,
fn E() -> Self
[src]
Return Euler’s number.
fn PI() -> Self
[src]
Return Archimedes’ constant.
fn SQRT_2() -> Self
[src]
Return sqrt(2.0)
.
fn FRAC_1_PI() -> Self
[src]
Return 1.0 / π
.
fn FRAC_2_PI() -> Self
[src]
Return 2.0 / π
.
fn FRAC_1_SQRT_2() -> Self
[src]
Return 1.0 / sqrt(2.0)
.
fn FRAC_2_SQRT_PI() -> Self
[src]
Return 2.0 / sqrt(π)
.
fn FRAC_PI_2() -> Self
[src]
Return π / 2.0
.
fn FRAC_PI_3() -> Self
[src]
Return π / 3.0
.
fn FRAC_PI_4() -> Self
[src]
Return π / 4.0
.
fn FRAC_PI_6() -> Self
[src]
Return π / 6.0
.
fn FRAC_PI_8() -> Self
[src]
Return π / 8.0
.
fn LN_10() -> Self
[src]
Return ln(10.0)
.
fn LN_2() -> Self
[src]
Return ln(2.0)
.
fn LOG10_E() -> Self
[src]
Return log10(e)
.
fn LOG2_E() -> Self
[src]
Return log2(e)
.
impl<T, P> FromPrimitive for ConstrainedFloat<T, P> where
T: Float + FromPrimitive,
P: FloatConstraint<T>,
[src]
T: Float + FromPrimitive,
P: FloatConstraint<T>,
fn from_i8(value: i8) -> Option<Self>
[src]
Convert an i8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u8(value: u8) -> Option<Self>
[src]
Convert an u8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i16(value: i16) -> Option<Self>
[src]
Convert an i16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u16(value: u16) -> Option<Self>
[src]
Convert an u16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i32(value: i32) -> Option<Self>
[src]
Convert an i32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u32(value: u32) -> Option<Self>
[src]
Convert an u32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i64(value: i64) -> Option<Self>
[src]
Convert an i64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u64(value: u64) -> Option<Self>
[src]
Convert an u64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_isize(value: isize) -> Option<Self>
[src]
Convert an isize
to return an optional value of this type. If the value cannot be represented by this value, the None
is returned. Read more
fn from_usize(value: usize) -> Option<Self>
[src]
Convert a usize
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f32(value: f32) -> Option<Self>
[src]
Convert a f32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f64(value: f64) -> Option<Self>
[src]
Convert a f64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
impl<T, P> Hash for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Infinite for ConstrainedFloat<T, NotNanConstraint<T>> where
T: Float,
[src]
T: Float,
fn infinity() -> Self
[src]
fn neg_infinity() -> Self
[src]
fn is_infinite(self) -> bool
[src]
fn is_finite(self) -> bool
[src]
impl<T, P> Mul for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
Performs the *
operation.
impl<T, P> Mul<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: T) -> Self::Output
[src]
Performs the *
operation.
impl<T, P> MulAssign for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn mul_assign(&mut self, other: Self)
[src]
Performs the *=
operation.
impl<T, P> MulAssign<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn mul_assign(&mut self, other: T)
[src]
Performs the *=
operation.
impl<T, P> Neg for ConstrainedFloat<T, P> where
T: Float + Num,
P: FloatConstraint<T>,
[src]
T: Float + Num,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
Performs the unary -
operation.
impl<T, P> Num for ConstrainedFloat<T, P> where
T: Float + Num,
P: FloatConstraint<T>,
[src]
T: Float + Num,
P: FloatConstraint<T>,
type FromStrRadixErr = ()
fn from_str_radix(
source: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
[src]
source: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
Convert from a string and radix <= 36. Read more
impl<T, P> NumCast for ConstrainedFloat<T, P> where
T: Float + Num,
P: FloatConstraint<T>,
[src]
T: Float + Num,
P: FloatConstraint<T>,
fn from<U>(value: U) -> Option<Self> where
U: ToPrimitive,
[src]
U: ToPrimitive,
Creates a number from another value that can be converted into a primitive via the ToPrimitive
trait. Read more
impl<T, P> One for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
impl<T, P> Ord for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<T, P> PartialEq for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T, P> PartialOrd for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
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
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
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
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<T, P> Real for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn max_value() -> Self
[src]
fn min_value() -> Self
[src]
fn min_positive_value() -> Self
[src]
fn neg_zero() -> Self
[src]
fn is_sign_positive(self) -> bool
[src]
fn is_sign_negative(self) -> bool
[src]
fn classify(self) -> FpCategory
[src]
fn is_normal(self) -> bool
[src]
fn integer_decode(self) -> (u64, i16, i8)
[src]
fn hypot(self, other: Self) -> Self
[src]
fn sin(self) -> Self
[src]
fn cos(self) -> Self
[src]
fn tan(self) -> Self
[src]
fn asin(self) -> Self
[src]
fn acos(self) -> Self
[src]
fn atan(self) -> Self
[src]
fn atan2(self, other: Self) -> Self
[src]
fn sin_cos(self) -> (Self, Self)
[src]
fn sinh(self) -> Self
[src]
fn cosh(self) -> Self
[src]
fn tanh(self) -> Self
[src]
fn asinh(self) -> Self
[src]
fn acosh(self) -> Self
[src]
fn atanh(self) -> Self
[src]
impl<T, P> Rem for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: Self) -> Self::Output
[src]
Performs the %
operation.
impl<T, P> Rem<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: T) -> Self::Output
[src]
Performs the %
operation.
impl<T, P> RemAssign for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn rem_assign(&mut self, other: Self)
[src]
Performs the %=
operation.
impl<T, P> RemAssign<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn rem_assign(&mut self, other: T)
[src]
Performs the %=
operation.
impl<T, P> Signed for ConstrainedFloat<T, P> where
T: Float + Signed,
P: FloatConstraint<T>,
[src]
T: Float + Signed,
P: FloatConstraint<T>,
fn abs(&self) -> Self
[src]
Computes the absolute value. Read more
fn abs_sub(&self, other: &Self) -> Self
[src]
The positive difference of two numbers. Read more
fn signum(&self) -> Self
[src]
Returns the sign of the number. Read more
fn is_positive(&self) -> bool
[src]
Returns true if the number is positive and false if the number is zero or negative.
fn is_negative(&self) -> bool
[src]
Returns true if the number is negative and false if the number is zero or positive.
impl<T, P> Sub for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self::Output
[src]
Performs the -
operation.
impl<T, P> Sub<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: T) -> Self::Output
[src]
Performs the -
operation.
impl<T, P> SubAssign for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn sub_assign(&mut self, other: Self)
[src]
Performs the -=
operation.
impl<T, P> SubAssign<T> for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,
fn sub_assign(&mut self, other: T)
[src]
Performs the -=
operation.
impl<T, P> ToPrimitive for ConstrainedFloat<T, P> where
T: Float + ToPrimitive,
P: FloatConstraint<T>,
[src]
T: Float + ToPrimitive,
P: FloatConstraint<T>,
fn to_i8(&self) -> Option<i8>
[src]
Converts the value of self
to an i8
.
fn to_u8(&self) -> Option<u8>
[src]
Converts the value of self
to an u8
.
fn to_i16(&self) -> Option<i16>
[src]
Converts the value of self
to an i16
.
fn to_u16(&self) -> Option<u16>
[src]
Converts the value of self
to an u16
.
fn to_i32(&self) -> Option<i32>
[src]
Converts the value of self
to an i32
.
fn to_u32(&self) -> Option<u32>
[src]
Converts the value of self
to an u32
.
fn to_i64(&self) -> Option<i64>
[src]
Converts the value of self
to an i64
.
fn to_u64(&self) -> Option<u64>
[src]
Converts the value of self
to an u64
.
fn to_isize(&self) -> Option<isize>
[src]
Converts the value of self
to an isize
.
fn to_usize(&self) -> Option<usize>
[src]
Converts the value of self
to a usize
.
fn to_f32(&self) -> Option<f32>
[src]
Converts the value of self
to an f32
.
fn to_f64(&self) -> Option<f64>
[src]
Converts the value of self
to an f64
.
impl<T, P> Zero for ConstrainedFloat<T, P> where
T: Float,
P: FloatConstraint<T>,
[src]
T: Float,
P: FloatConstraint<T>,