pub struct Probability(/* private fields */);Expand description
Probability as f64 in the range 0.0..=1.0.
Use this for rates, weights, and sampling. For a 0..=100 percentage use
PercentFloat; for an integer percentage use Percent.
Implementations§
Source§impl Probability
impl Probability
Sourcepub fn new(value: f64) -> PrimitiveResult<Self>
pub fn new(value: f64) -> PrimitiveResult<Self>
Creates a Probability. Returns Invalid if value is not finite or is
outside 0.0..=1.0.
Sourcepub fn complement(self) -> Self
pub fn complement(self) -> Self
Returns the complementary probability, 1.0 - p. Always valid because
the complement of a value in 0.0..=1.0 is itself in 0.0..=1.0.
Trait Implementations§
Source§impl Clone for Probability
impl Clone for Probability
Source§fn clone(&self) -> Probability
fn clone(&self) -> Probability
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 moreimpl Copy for Probability
Source§impl Debug for Probability
impl Debug for Probability
Source§impl Display for Probability
impl Display for Probability
Source§impl PartialEq for Probability
impl PartialEq for Probability
Source§fn eq(&self, other: &Probability) -> bool
fn eq(&self, other: &Probability) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for Probability
impl PartialOrd for Probability
impl StructuralPartialEq for Probability
Auto Trait Implementations§
impl Freeze for Probability
impl RefUnwindSafe for Probability
impl Send for Probability
impl Sync for Probability
impl Unpin for Probability
impl UnsafeUnpin for Probability
impl UnwindSafe for Probability
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