Skip to main content

UnitInterval

Struct UnitInterval 

Source
pub struct UnitInterval<T = f32>(/* private fields */);
Expand description

A floating-point value constrained to the closed unit interval [0, 1].

UnitInterval is useful for normalized values such as opacity, progress, ratios, blend factors, and percentages represented as fractions.

The default backing type is f32; use UnitInterval<f64> when you need a wider float.

§Examples

use unit_intervals::UnitInterval;

let progress = UnitInterval::new(0.75).unwrap();

assert_eq!(progress.get(), 0.75);
assert_eq!(UnitInterval::new(1.25), None);

Implementations§

Source§

impl<T: UnitIntervalFloat> UnitInterval<T>

Source

pub const ZERO: Self

The lower bound of the unit interval.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::ZERO.get(), 0.0);
Source

pub const ONE: Self

The upper bound of the unit interval.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::ONE.get(), 1.0);
Source

pub const HALF: Self

The midpoint of the unit interval.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::HALF.get(), 0.5);
Source

pub fn new(v: T) -> Option<Self>

Creates a value if v is inside [0, 1].

Returns None for values outside the interval and for NaN.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::new(0.25).unwrap().get(), 0.25);
assert_eq!(UnitInterval::<f32>::new(-0.25), None);
assert_eq!(UnitInterval::<f32>::new(f32::NAN), None);
Source

pub const unsafe fn new_unchecked(v: T) -> Self

Available on crate feature unsafe only.

Creates a value without checking that v is inside [0, 1].

§Safety

The caller must guarantee that v is greater than or equal to zero, less than or equal to one, and not NaN.

Source

pub fn contains(v: T) -> bool

Returns whether v is inside [0, 1].

NaN is not contained in the interval.

§Examples
use unit_intervals::UnitInterval;

assert!(UnitInterval::<f32>::contains(0.5));
assert!(!UnitInterval::<f32>::contains(1.5));
assert!(!UnitInterval::<f32>::contains(f32::NAN));
Source

pub fn saturating(v: T) -> Self

Creates a value by clamping v into [0, 1].

NaN is treated as zero.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::saturating(-0.25).get(), 0.0);
assert_eq!(UnitInterval::<f32>::saturating(1.25).get(), 1.0);
assert_eq!(UnitInterval::<f32>::saturating(f32::NAN).get(), 0.0);
Source

pub const fn get(self) -> T

Returns the inner floating-point value.

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.25).unwrap();

assert_eq!(value.get(), 0.25);
Source

pub const fn into_inner(self) -> T

Consumes the wrapper and returns the inner floating-point value.

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.25).unwrap();

assert_eq!(value.into_inner(), 0.25);
Source

pub fn is_zero(self) -> bool

Returns whether this value is exactly zero.

§Examples
use unit_intervals::UnitInterval;

assert!(UnitInterval::<f32>::ZERO.is_zero());
assert!(!UnitInterval::<f32>::HALF.is_zero());
Source

pub fn is_one(self) -> bool

Returns whether this value is exactly one.

§Examples
use unit_intervals::UnitInterval;

assert!(UnitInterval::<f32>::ONE.is_one());
assert!(!UnitInterval::<f32>::HALF.is_one());
Source

pub fn complement(self) -> Self

Returns 1 - self.

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.25).unwrap();

assert_eq!(value.complement().get(), 0.75);
Source

pub fn min(self, rhs: Self) -> Self

Returns the smaller of two unit interval values.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.min(high), low);
Source

pub fn max(self, rhs: Self) -> Self

Returns the larger of two unit interval values.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.max(high), high);
Source

pub fn midpoint(self, rhs: Self) -> Self

Returns the midpoint between two unit interval values.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.midpoint(high).get(), 0.5);
Source

pub fn distance_to(self, rhs: Self) -> Self

Returns the absolute distance between two unit interval values.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.distance_to(high).get(), 0.5);
assert_eq!(high.distance_to(low).get(), 0.5);
Source

pub fn checked_add(self, rhs: Self) -> Option<Self>

Adds two values, returning None if the result is outside [0, 1].

§Examples
use unit_intervals::UnitInterval;

let a = UnitInterval::new(0.25).unwrap();
let b = UnitInterval::new(0.75).unwrap();

assert_eq!(a.checked_add(a).unwrap().get(), 0.5);
assert_eq!(b.checked_add(b), None);
Source

pub unsafe fn add_unchecked(self, rhs: Self) -> Self

Available on crate feature unsafe only.

Adds two values without checking that the result is inside [0, 1].

§Safety

The caller must guarantee that self + rhs is inside [0, 1] and not NaN.

Source

pub fn saturating_add(self, rhs: Self) -> Self

Adds two values and clamps the result into [0, 1].

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.75).unwrap();

assert_eq!(value.saturating_add(value).get(), 1.0);
Source

pub fn checked_sub(self, rhs: Self) -> Option<Self>

Subtracts rhs, returning None if the result is outside [0, 1].

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(high.checked_sub(low).unwrap().get(), 0.5);
assert_eq!(low.checked_sub(high), None);
Source

pub unsafe fn sub_unchecked(self, rhs: Self) -> Self

Available on crate feature unsafe only.

Subtracts rhs without checking that the result is inside [0, 1].

§Safety

The caller must guarantee that self - rhs is inside [0, 1] and not NaN.

Source

pub fn saturating_sub(self, rhs: Self) -> Self

Subtracts rhs and clamps the result into [0, 1].

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.saturating_sub(high).get(), 0.0);
Source

pub fn checked_div(self, rhs: Self) -> Option<Self>

Divides by rhs, returning None if the result is outside [0, 1].

Division by zero follows the backing float semantics and produces None, because infinity is outside the unit interval.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(low.checked_div(high).unwrap().get(), 1.0 / 3.0);
assert_eq!(high.checked_div(low), None);
assert_eq!(high.checked_div(UnitInterval::ZERO), None);
Source

pub unsafe fn div_unchecked(self, rhs: Self) -> Self

Available on crate feature unsafe only.

Divides by rhs without checking that the result is inside [0, 1].

§Safety

The caller must guarantee that self / rhs is inside [0, 1] and not NaN.

Source

pub fn saturating_div(self, rhs: Self) -> Self

Divides by rhs and clamps the result into [0, 1].

Division by zero follows the backing float semantics and saturates to one for positive infinity, or zero for 0 / 0.

§Examples
use unit_intervals::UnitInterval;

let low = UnitInterval::new(0.25).unwrap();
let high = UnitInterval::new(0.75).unwrap();

assert_eq!(high.saturating_div(low).get(), 1.0);
assert_eq!(low.saturating_div(UnitInterval::ZERO).get(), 1.0);
Source

pub fn checked_scale(self, factor: T) -> Option<Self>

Multiplies by an arbitrary float, returning None if the result is outside [0, 1].

Use the * operator when multiplying by another UnitInterval, since that operation always stays inside the interval.

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.25).unwrap();

assert_eq!(value.checked_scale(2.0).unwrap().get(), 0.5);
assert_eq!(value.checked_scale(8.0), None);
Source

pub unsafe fn scale_unchecked(self, factor: T) -> Self

Available on crate feature unsafe only.

Multiplies by an arbitrary float without checking that the result is inside [0, 1].

§Safety

The caller must guarantee that self * factor is inside [0, 1] and not NaN.

Source

pub fn saturating_scale(self, factor: T) -> Self

Multiplies by an arbitrary float and clamps the result into [0, 1].

Use the * operator when multiplying by another UnitInterval, since that operation always stays inside the interval.

§Examples
use unit_intervals::UnitInterval;

let value = UnitInterval::new(0.75).unwrap();

assert_eq!(value.saturating_scale(2.0).get(), 1.0);
assert_eq!(value.saturating_scale(-1.0).get(), 0.0);
Source

pub fn lerp(self, start: T, end: T) -> T

Linearly interpolates between start and end.

A value of zero returns start, one returns end, and values between zero and one return the corresponding point between them.

§Examples
use unit_intervals::UnitInterval;

assert_eq!(UnitInterval::<f32>::ZERO.lerp(10.0, 20.0), 10.0);
assert_eq!(UnitInterval::<f32>::HALF.lerp(10.0, 20.0), 15.0);
assert_eq!(UnitInterval::<f32>::ONE.lerp(10.0, 20.0), 20.0);
Source§

impl UnitInterval<f32>

Source

pub fn abs(self) -> Self

Returns the absolute value.

Source

pub fn signum(self) -> f32

Returns a number representing the sign of this value.

Source

pub fn copysign(self, sign: f32) -> f32

Returns this value with the sign of sign.

Source

pub fn is_sign_positive(self) -> bool

Returns true if this value is positive zero.

Source

pub fn is_sign_negative(self) -> bool

Returns true if this value is negative zero.

Source

pub fn is_finite(self) -> bool

Returns true; unit interval values are always finite.

Source

pub fn is_infinite(self) -> bool

Returns false; unit interval values cannot be infinite.

Source

pub fn is_nan(self) -> bool

Returns false; unit interval values cannot be NaN.

Source

pub fn recip(self) -> f32

Takes the reciprocal, 1 / self.

Source§

impl UnitInterval<f32>

Source

pub fn floor(self) -> Self

Available on crate features std only.

Returns the largest integer less than or equal to this value.

Source

pub fn ceil(self) -> Self

Available on crate features std only.

Returns the smallest integer greater than or equal to this value.

Source

pub fn round(self) -> Self

Available on crate features std only.

Returns the nearest integer to this value, rounding halfway cases away from zero.

Source

pub fn trunc(self) -> Self

Available on crate features std only.

Returns the integer part of this value.

Source

pub fn fract(self) -> Self

Available on crate features std only.

Returns the fractional part of this value.

Source

pub fn powi(self, n: i32) -> f32

Available on crate features std only.

Raises this value to an integer power.

Source

pub fn powf(self, n: f32) -> f32

Available on crate features std only.

Raises this value to a floating-point power.

Source

pub fn sqrt(self) -> Self

Available on crate features std only.

Returns the square root.

Source

pub fn cbrt(self) -> Self

Available on crate features std only.

Returns the cube root.

Source

pub fn mul_add(self, a: f32, b: f32) -> f32

Available on crate features std only.

Computes self * a + b with one rounding error.

Source

pub fn div_euclid(self, rhs: f32) -> f32

Available on crate features std only.

Returns the Euclidean division of this value by rhs.

Source

pub fn rem_euclid(self, rhs: f32) -> f32

Available on crate features std only.

Returns the least non-negative remainder of this value divided by rhs.

Source

pub fn exp(self) -> f32

Available on crate features std only.

Returns e^(self).

Source

pub fn exp2(self) -> f32

Available on crate features std only.

Returns 2^(self).

Source

pub fn ln(self) -> f32

Available on crate features std only.

Returns the natural logarithm.

Source

pub fn log(self, base: f32) -> f32

Available on crate features std only.

Returns the logarithm with respect to an arbitrary base.

Source

pub fn log2(self) -> f32

Available on crate features std only.

Returns the base 2 logarithm.

Source

pub fn log10(self) -> f32

Available on crate features std only.

Returns the base 10 logarithm.

Source

pub fn sin(self) -> f32

Available on crate features std only.

Returns the sine, in radians.

Source

pub fn cos(self) -> f32

Available on crate features std only.

Returns the cosine, in radians.

Source

pub fn tan(self) -> f32

Available on crate features std only.

Returns the tangent, in radians.

Source

pub fn sin_cos(self) -> (f32, f32)

Available on crate features std only.

Returns both sine and cosine, in radians.

Source

pub fn asin(self) -> f32

Available on crate features std only.

Returns the arcsine, in radians.

Source

pub fn acos(self) -> f32

Available on crate features std only.

Returns the arccosine, in radians.

Source

pub fn atan(self) -> Self

Available on crate features std only.

Returns the arctangent, in radians.

Source

pub fn atan2(self, other: f32) -> f32

Available on crate features std only.

Returns the four-quadrant arctangent of self and other, in radians.

Source

pub fn sinh(self) -> f32

Available on crate features std only.

Returns the hyperbolic sine.

Source

pub fn cosh(self) -> f32

Available on crate features std only.

Returns the hyperbolic cosine.

Source

pub fn tanh(self) -> Self

Available on crate features std only.

Returns the hyperbolic tangent.

Source

pub fn asinh(self) -> Self

Available on crate features std only.

Returns the inverse hyperbolic sine.

Source

pub fn acosh(self) -> f32

Available on crate features std only.

Returns the inverse hyperbolic cosine.

Source

pub fn atanh(self) -> f32

Available on crate features std only.

Returns the inverse hyperbolic tangent.

Source

pub fn hypot(self, other: f32) -> f32

Available on crate features std only.

Calculates the length of the hypotenuse of a right-angle triangle.

Source§

impl UnitInterval<f64>

Source

pub fn abs(self) -> Self

Returns the absolute value.

Source

pub fn signum(self) -> f64

Returns a number representing the sign of this value.

Source

pub fn copysign(self, sign: f64) -> f64

Returns this value with the sign of sign.

Source

pub fn is_sign_positive(self) -> bool

Returns true if this value is positive zero.

Source

pub fn is_sign_negative(self) -> bool

Returns true if this value is negative zero.

Source

pub fn is_finite(self) -> bool

Returns true; unit interval values are always finite.

Source

pub fn is_infinite(self) -> bool

Returns false; unit interval values cannot be infinite.

Source

pub fn is_nan(self) -> bool

Returns false; unit interval values cannot be NaN.

Source

pub fn recip(self) -> f64

Takes the reciprocal, 1 / self.

Source§

impl UnitInterval<f64>

Source

pub fn floor(self) -> Self

Available on crate features std only.

Returns the largest integer less than or equal to this value.

Source

pub fn ceil(self) -> Self

Available on crate features std only.

Returns the smallest integer greater than or equal to this value.

Source

pub fn round(self) -> Self

Available on crate features std only.

Returns the nearest integer to this value, rounding halfway cases away from zero.

Source

pub fn trunc(self) -> Self

Available on crate features std only.

Returns the integer part of this value.

Source

pub fn fract(self) -> Self

Available on crate features std only.

Returns the fractional part of this value.

Source

pub fn powi(self, n: i32) -> f64

Available on crate features std only.

Raises this value to an integer power.

Source

pub fn powf(self, n: f64) -> f64

Available on crate features std only.

Raises this value to a floating-point power.

Source

pub fn sqrt(self) -> Self

Available on crate features std only.

Returns the square root.

Source

pub fn cbrt(self) -> Self

Available on crate features std only.

Returns the cube root.

Source

pub fn mul_add(self, a: f64, b: f64) -> f64

Available on crate features std only.

Computes self * a + b with one rounding error.

Source

pub fn div_euclid(self, rhs: f64) -> f64

Available on crate features std only.

Returns the Euclidean division of this value by rhs.

Source

pub fn rem_euclid(self, rhs: f64) -> f64

Available on crate features std only.

Returns the least non-negative remainder of this value divided by rhs.

Source

pub fn exp(self) -> f64

Available on crate features std only.

Returns e^(self).

Source

pub fn exp2(self) -> f64

Available on crate features std only.

Returns 2^(self).

Source

pub fn ln(self) -> f64

Available on crate features std only.

Returns the natural logarithm.

Source

pub fn log(self, base: f64) -> f64

Available on crate features std only.

Returns the logarithm with respect to an arbitrary base.

Source

pub fn log2(self) -> f64

Available on crate features std only.

Returns the base 2 logarithm.

Source

pub fn log10(self) -> f64

Available on crate features std only.

Returns the base 10 logarithm.

Source

pub fn sin(self) -> f64

Available on crate features std only.

Returns the sine, in radians.

Source

pub fn cos(self) -> f64

Available on crate features std only.

Returns the cosine, in radians.

Source

pub fn tan(self) -> f64

Available on crate features std only.

Returns the tangent, in radians.

Source

pub fn sin_cos(self) -> (f64, f64)

Available on crate features std only.

Returns both sine and cosine, in radians.

Source

pub fn asin(self) -> f64

Available on crate features std only.

Returns the arcsine, in radians.

Source

pub fn acos(self) -> f64

Available on crate features std only.

Returns the arccosine, in radians.

Source

pub fn atan(self) -> Self

Available on crate features std only.

Returns the arctangent, in radians.

Source

pub fn atan2(self, other: f64) -> f64

Available on crate features std only.

Returns the four-quadrant arctangent of self and other, in radians.

Source

pub fn sinh(self) -> f64

Available on crate features std only.

Returns the hyperbolic sine.

Source

pub fn cosh(self) -> f64

Available on crate features std only.

Returns the hyperbolic cosine.

Source

pub fn tanh(self) -> Self

Available on crate features std only.

Returns the hyperbolic tangent.

Source

pub fn asinh(self) -> Self

Available on crate features std only.

Returns the inverse hyperbolic sine.

Source

pub fn acosh(self) -> f64

Available on crate features std only.

Returns the inverse hyperbolic cosine.

Source

pub fn atanh(self) -> f64

Available on crate features std only.

Returns the inverse hyperbolic tangent.

Source

pub fn hypot(self, other: f64) -> f64

Available on crate features std only.

Calculates the length of the hypotenuse of a right-angle triangle.

Trait Implementations§

Source§

impl Add<SignedUnitInterval<f64>> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: SignedUnitInterval<f64>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<SignedUnitInterval> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the + operator.
Source§

fn add(self, rhs: SignedUnitInterval<f32>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<UnitInterval<f64>> for SignedUnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<UnitInterval<f64>> for f64

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<UnitInterval> for SignedUnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the + operator.
Source§

fn add(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<UnitInterval> for f32

Source§

type Output = f32

The resulting type after applying the + operator.
Source§

fn add(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f32> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Arbitrary<'a> for UnitInterval<f32>

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<'a> Arbitrary<'a> for UnitInterval<f64>

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<T> Archive for UnitInterval<T>
where T: Archive,

Source§

type Archived = ArchivedUnitInterval<T>

The archived representation of this type. Read more
Source§

type Resolver = UnitIntervalResolver<T>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl AsPrimitive<UnitInterval<f64>> for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn as_(self) -> UnitInterval<f64>

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<UnitInterval<f64>> for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn as_(self) -> UnitInterval<f64>

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<UnitInterval> for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn as_(self) -> UnitInterval<f32>

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<UnitInterval> for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn as_(self) -> UnitInterval<f32>

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<f32> for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn as_(self) -> f32

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<f32> for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn as_(self) -> f32

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<f64> for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn as_(self) -> f64

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<f64> for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn as_(self) -> f64

Convert a value to another, using the as operator.
Source§

impl<T> AsRef<T> for UnitInterval<T>

Borrows the inner floating-point value.

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Bounded for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Self

Returns the largest finite number this type can represent
Source§

impl Bounded for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Self

Returns the largest finite number this type can represent
Source§

impl<T> CheckedBitPattern for UnitInterval<T>

Available on crate feature bytemuck only.
Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(bits: &Self::Bits) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl CheckedMul for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn checked_mul(&self, v: &Self) -> Option<Self>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
Source§

impl CheckedMul for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn checked_mul(&self, v: &Self) -> Option<Self>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
Source§

impl<T: Clone> Clone for UnitInterval<T>

Source§

fn clone(&self) -> UnitInterval<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConstOne for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

const ONE: Self = Self::ONE

The multiplicative identity element of Self, 1.
Source§

impl ConstOne for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

const ONE: Self = Self::ONE

The multiplicative identity element of Self, 1.
Source§

impl<T: Debug> Debug for UnitInterval<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: UnitIntervalFloat> Default for UnitInterval<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Deref for UnitInterval<T>

Dereferences to the inner floating-point value.

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for UnitInterval<T>

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, D> Distribution<UnitInterval<T>> for SaturatingUnitIntervalDistribution<D>

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<T>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl<T> Distribution<UnitInterval<T>> for StandardUniform

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<T>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval<f64>> for Beta<f64>

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f64>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval<f64>> for Open01

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f64>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval<f64>> for OpenClosed01

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f64>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval> for Beta<f32>

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f32>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval> for Open01

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f32>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Distribution<UnitInterval> for OpenClosed01

Available on crate feature rand_distr only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitInterval<f32>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Div<SignedUnitInterval<f64>> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: SignedUnitInterval<f64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<SignedUnitInterval> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: SignedUnitInterval<f32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<UnitInterval<f64>> for SignedUnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<UnitInterval<f64>> for f64

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<UnitInterval> for SignedUnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<UnitInterval> for f32

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f32> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: UnitIntervalFloat> From<UnitInterval<T>> for SignedUnitInterval<T>

Source§

fn from(u: UnitInterval<T>) -> Self

Converts to this type from the input type.
Source§

impl From<UnitInterval<f64>> for UnitInterval<f32>

Converts a UnitInterval<f64> into UnitInterval<f32>.

Source§

fn from(u: UnitInterval<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<UnitInterval<f64>> for f64

Source§

fn from(u: UnitInterval<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<UnitInterval> for UnitInterval<f64>

Converts a UnitInterval<f32> into UnitInterval<f64>.

Source§

fn from(u: UnitInterval<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<UnitInterval> for f32

Source§

fn from(u: UnitInterval<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<UnitInterval> for f64

Converts a UnitInterval<f32> into its inner value widened to f64.

Source§

fn from(u: UnitInterval) -> Self

Converts to this type from the input type.
Source§

impl FromPrimitive for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl FromPrimitive for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl<T: UnitIntervalFloat> Mul<SignedUnitInterval<T>> for UnitInterval<T>

Multiplies a unit interval by a signed unit interval.

Source§

type Output = SignedUnitInterval<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: SignedUnitInterval<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: UnitIntervalFloat> Mul<UnitInterval<T>> for SignedUnitInterval<T>

Multiplies a signed unit interval by a unit interval.

Source§

type Output = SignedUnitInterval<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: UnitInterval<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<UnitInterval<f64>> for f64

Source§

type Output = f64

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<UnitInterval> for f32

Source§

type Output = f32

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: UnitIntervalFloat> Mul for UnitInterval<T>

Multiplies two unit interval values.

Multiplication is implemented as an operator because the product of two values in [0, 1] is also in [0, 1].

§Examples

use unit_intervals::UnitInterval;

let a = UnitInterval::new(0.25).unwrap();
let b = UnitInterval::new(0.75).unwrap();

assert_eq!((a * b).get(), 0.1875);
Source§

type Output = UnitInterval<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl NumCast for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn from<T: ToPrimitive>(n: T) -> Option<Self>

Creates a number from another value that can be converted into a primitive via the ToPrimitive trait. If the source value cannot be represented by the target type, then None is returned. Read more
Source§

impl NumCast for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn from<T: ToPrimitive>(n: T) -> Option<Self>

Creates a number from another value that can be converted into a primitive via the ToPrimitive trait. If the source value cannot be represented by the target type, then None is returned. Read more
Source§

impl One for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

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

impl One for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

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

impl PartialEq<UnitInterval<f64>> for f64

Source§

fn eq(&self, other: &UnitInterval<f64>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<UnitInterval> for f32

Source§

fn eq(&self, other: &UnitInterval<f32>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f32> for UnitInterval<f32>

Source§

fn eq(&self, other: &f32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for UnitInterval<f64>

Source§

fn eq(&self, other: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq> PartialEq for UnitInterval<T>

Source§

fn eq(&self, other: &UnitInterval<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<UnitInterval<f64>> for f64

Source§

fn partial_cmp(&self, other: &UnitInterval<f64>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<UnitInterval> for f32

Source§

fn partial_cmp(&self, other: &UnitInterval<f32>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f32> for UnitInterval<f32>

Source§

fn partial_cmp(&self, other: &f32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for UnitInterval<f64>

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialOrd> PartialOrd for UnitInterval<T>

Source§

fn partial_cmp(&self, other: &UnitInterval<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u16> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u16) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u16> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u16) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u32> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u32) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u32> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u32) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u8> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u8) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&u8> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &u8) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&usize> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &usize) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<&usize> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: &usize) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u16> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u16) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u16> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u16) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u32> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u32) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u32> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u32) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u8> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u8) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<u8> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: u8) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<usize> for &UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: usize) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<T: UnitIntervalFloat> Pow<usize> for UnitInterval<T>

Available on crate feature num-traits only.
Source§

type Output = UnitInterval<T>

The result after applying the operator.
Source§

fn pow(self, rhs: usize) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Rem<SignedUnitInterval<f64>> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: SignedUnitInterval<f64>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<SignedUnitInterval> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: SignedUnitInterval<f32>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<UnitInterval<f64>> for SignedUnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<UnitInterval<f64>> for f64

Source§

type Output = f64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<UnitInterval> for SignedUnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<UnitInterval> for f32

Source§

type Output = f32

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f32> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f32) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f64> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl SaturatingMul for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn saturating_mul(&self, v: &Self) -> Self

Saturating multiplication. Computes self * other, saturating at the relevant high or low boundary of the type.
Source§

impl SaturatingMul for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn saturating_mul(&self, v: &Self) -> Self

Saturating multiplication. Computes self * other, saturating at the relevant high or low boundary of the type.
Source§

impl<__S: Fallible + ?Sized, T> Serialize<__S> for UnitInterval<T>
where T: Serialize<__S>,

Source§

fn serialize( &self, serializer: &mut __S, ) -> Result<<Self as Archive>::Resolver, <__S as Fallible>::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<T: Serialize> Serialize for UnitInterval<T>

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub<SignedUnitInterval<f64>> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: SignedUnitInterval<f64>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<SignedUnitInterval> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: SignedUnitInterval<f32>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<UnitInterval<f64>> for SignedUnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<UnitInterval<f64>> for f64

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: UnitInterval<f64>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<UnitInterval> for SignedUnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<UnitInterval> for f32

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: UnitInterval<f32>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f32> for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for UnitInterval<f32>

Source§

type Output = f32

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for UnitInterval<f64>

Source§

type Output = f64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl ToBytes for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

type Bytes = <f32 as ToBytes>::Bytes

Source§

fn to_be_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in big-endian byte order. Read more
Source§

fn to_le_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in little-endian byte order. Read more
Source§

fn to_ne_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in native byte order. Read more
Source§

impl ToBytes for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

type Bytes = <f64 as ToBytes>::Bytes

Source§

fn to_be_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in big-endian byte order. Read more
Source§

fn to_le_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in little-endian byte order. Read more
Source§

fn to_ne_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in native byte order. Read more
Source§

impl ToPrimitive for UnitInterval<f32>

Available on crate feature num-traits only.
Source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Source§

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

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Source§

fn to_f32(&self) -> Option<f32>

Converts the value of 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.
Source§

fn to_f64(&self) -> Option<f64>

Converts the value of 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 more
Source§

impl ToPrimitive for UnitInterval<f64>

Available on crate feature num-traits only.
Source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Source§

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

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Source§

fn to_f32(&self) -> Option<f32>

Converts the value of 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.
Source§

fn to_f64(&self) -> Option<f64>

Converts the value of 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 more
Source§

impl<T: UnitIntervalFloat> TryFrom<SignedUnitInterval<T>> for UnitInterval<T>

Source§

type Error = UnitIntervalError

The type returned in the event of a conversion error.
Source§

fn try_from(value: SignedUnitInterval<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f32> for UnitInterval<f32>

Source§

type Error = UnitIntervalError

The type returned in the event of a conversion error.
Source§

fn try_from(value: f32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for UnitInterval<f64>

Source§

type Error = UnitIntervalError

The type returned in the event of a conversion error.
Source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> Zeroable for UnitInterval<T>

Available on crate feature bytemuck only.
Source§

fn zeroed() -> Self

Source§

impl<T: Copy> Copy for UnitInterval<T>

Source§

impl<T> NoUninit for UnitInterval<T>

Available on crate feature bytemuck only.
Source§

impl<T> StructuralPartialEq for UnitInterval<T>

Auto Trait Implementations§

§

impl<T> Freeze for UnitInterval<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for UnitInterval<T>
where T: RefUnwindSafe,

§

impl<T> Send for UnitInterval<T>
where T: Send,

§

impl<T> Sync for UnitInterval<T>
where T: Sync,

§

impl<T> Unpin for UnitInterval<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for UnitInterval<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for UnitInterval<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,