pub struct NonNegativeRate(/* private fields */);Expand description
A finite, non-negative f32 rate, valid by construction.
A NonNegativeRate can never hold a NaN, an infinity, or a negative: the
invariant is is_finite() && r >= 0.0. Unlike
Probability it has no upper bound —
it is the right type for an unbounded magnitude such as BLX-α’s expansion
factor or Gaussian mutation’s σ, where the hazard is a NaN/Inf poisoning
the offspring tensor rather than an out-of-[0,1] saturation.
Construct with new for literals (panics on an invalid value)
or try_new for runtime data (returns
NonNegativeRateError). Deserialize routes through try_new via
TryFrom, so a rate loaded from a file cannot deserialize into a
non-finite or negative NonNegativeRate.
Implementations§
Source§impl NonNegativeRate
impl NonNegativeRate
Sourcepub const fn new(r: f32) -> Self
pub const fn new(r: f32) -> Self
Builds a rate from a compile-time-known value, panicking on an invalid one.
This is the constructor for literals and Defaults — the bad value is
right at the call site, mirroring the documented builder-setter panic
exception of ADR 0026. Prefer try_new for any value
derived from runtime or user-supplied data.
§Panics
Panics when r is negative, NaN, or infinite.
Sourcepub fn try_new(r: f32) -> Result<Self, NonNegativeRateError>
pub fn try_new(r: f32) -> Result<Self, NonNegativeRateError>
Builds a rate from a runtime / user-supplied value.
§Errors
Returns NonNegativeRateError when r is negative, NaN, or
infinite.
Trait Implementations§
Source§impl Clone for NonNegativeRate
impl Clone for NonNegativeRate
Source§fn clone(&self) -> NonNegativeRate
fn clone(&self) -> NonNegativeRate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for NonNegativeRate
Source§impl Debug for NonNegativeRate
impl Debug for NonNegativeRate
Source§impl<'de> Deserialize<'de> for NonNegativeRate
impl<'de> Deserialize<'de> for NonNegativeRate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<NonNegativeRate> for f32
impl From<NonNegativeRate> for f32
Source§fn from(r: NonNegativeRate) -> Self
fn from(r: NonNegativeRate) -> Self
Source§impl PartialEq for NonNegativeRate
impl PartialEq for NonNegativeRate
Source§impl Serialize for NonNegativeRate
impl Serialize for NonNegativeRate
impl StructuralPartialEq for NonNegativeRate
Auto Trait Implementations§
impl Freeze for NonNegativeRate
impl RefUnwindSafe for NonNegativeRate
impl Send for NonNegativeRate
impl Sync for NonNegativeRate
impl Unpin for NonNegativeRate
impl UnsafeUnpin for NonNegativeRate
impl UnwindSafe for NonNegativeRate
Blanket Implementations§
impl<T> Boilerplate for T
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
Source§impl<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more