pub struct UnitInterval(/* private fields */);Expand description
Re-export canonical pack value types used by core public structs.
A finite value in the inclusive [0.0, 1.0] range.
Use this for confidence, normalized scores, prior weights, and thresholds.
Implementations§
Source§impl UnitInterval
impl UnitInterval
Sourcepub const ZERO: UnitInterval
pub const ZERO: UnitInterval
The minimum unit interval value.
Sourcepub const ONE: UnitInterval
pub const ONE: UnitInterval
The maximum unit interval value.
Sourcepub fn new(value: f64) -> Result<UnitInterval, UnitIntervalError>
pub fn new(value: f64) -> Result<UnitInterval, UnitIntervalError>
Create a validated unit interval.
Returns an error for NaN, infinity, or values outside [0.0, 1.0].
Sourcepub fn clamped(value: f64) -> UnitInterval
pub fn clamped(value: f64) -> UnitInterval
Create a unit interval by clamping finite input.
Non-finite values become 0.0.
Sourcepub fn saturating_add(self, delta: f64) -> UnitInterval
pub fn saturating_add(self, delta: f64) -> UnitInterval
Add a delta and clamp the result back into the valid range.
Sourcepub fn scale_by(self, factor: UnitInterval) -> UnitInterval
pub fn scale_by(self, factor: UnitInterval) -> UnitInterval
Multiply two unit interval values.
Sourcepub fn to_basis_points(self) -> u16
pub fn to_basis_points(self) -> u16
Convert to basis points, rounded to the nearest basis point.
Trait Implementations§
Source§impl Clone for UnitInterval
impl Clone for UnitInterval
Source§fn clone(&self) -> UnitInterval
fn clone(&self) -> UnitInterval
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UnitInterval
impl Debug for UnitInterval
Source§impl Default for UnitInterval
impl Default for UnitInterval
Source§fn default() -> UnitInterval
fn default() -> UnitInterval
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for UnitInterval
impl<'de> Deserialize<'de> for UnitInterval
Source§fn deserialize<D>(
deserializer: D,
) -> Result<UnitInterval, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<UnitInterval, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for UnitInterval
impl PartialEq for UnitInterval
Source§fn eq(&self, other: &UnitInterval) -> bool
fn eq(&self, other: &UnitInterval) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for UnitInterval
impl PartialOrd for UnitInterval
Source§impl Serialize for UnitInterval
impl Serialize for UnitInterval
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<f64> for UnitInterval
impl TryFrom<f64> for UnitInterval
Source§type Error = UnitIntervalError
type Error = UnitIntervalError
The type returned in the event of a conversion error.
Source§fn try_from(
value: f64,
) -> Result<UnitInterval, <UnitInterval as TryFrom<f64>>::Error>
fn try_from( value: f64, ) -> Result<UnitInterval, <UnitInterval as TryFrom<f64>>::Error>
Performs the conversion.
impl Copy for UnitInterval
impl StructuralPartialEq for UnitInterval
Auto Trait Implementations§
impl Freeze for UnitInterval
impl RefUnwindSafe for UnitInterval
impl Send for UnitInterval
impl Sync for UnitInterval
impl Unpin for UnitInterval
impl UnsafeUnpin for UnitInterval
impl UnwindSafe for UnitInterval
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more