Struct merino_suggest_traits::domain::Proportion  
source · [−]pub struct Proportion(u32);Expand description
Represents a value from 0.0 to 1.0, inclusive. That is: a portion of something that cannot be negative or exceed 100%.
Stored internally as a u32.
Tuple Fields
0: u32Implementations
sourceimpl Proportion
 
impl Proportion
sourcepub fn from<T>(v: T) -> Self where
    T: TryInto<Self>,
    <T as TryInto<Self>>::Error: Debug, 
 
pub fn from<T>(v: T) -> Self where
    T: TryInto<Self>,
    <T as TryInto<Self>>::Error: Debug, 
Converts a float value into a Proportion. Panics if the value is not between zero and one.
This is not implemented using [std::config::From] because you cannot
implement both Try and TryFrom for the same pair of types, due to a
blanket impl TryFor<T> for U where U: Try<T>.
Trait Implementations
sourceimpl Clone for Proportion
 
impl Clone for Proportion
sourcefn clone(&self) -> Proportion
 
fn clone(&self) -> Proportion
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Proportion
 
impl Debug for Proportion
sourceimpl Default for Proportion
 
impl Default for Proportion
sourcefn default() -> Proportion
 
fn default() -> Proportion
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for Proportion
 
impl<'de> Deserialize<'de> for Proportion
sourcefn 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>, 
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Distribution<Proportion> for Standard
 
impl Distribution<Proportion> for Standard
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Proportion
 
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Proportion
Generate a random value of T, using rng as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
    R: Rng, 
 
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
    R: Rng, 
Create an iterator that generates random values of T, using rng as
the source of randomness. Read more
sourceimpl From<&Proportion> for f32
 
impl From<&Proportion> for f32
sourcefn from(portion: &Proportion) -> f32
 
fn from(portion: &Proportion) -> f32
Converts to this type from the input type.
sourceimpl From<&Proportion> for f64
 
impl From<&Proportion> for f64
sourcefn from(portion: &Proportion) -> f64
 
fn from(portion: &Proportion) -> f64
Converts to this type from the input type.
sourceimpl From<Proportion> for f32
 
impl From<Proportion> for f32
sourcefn from(portion: Proportion) -> f32
 
fn from(portion: Proportion) -> f32
Converts to this type from the input type.
sourceimpl From<Proportion> for f64
 
impl From<Proportion> for f64
sourcefn from(portion: Proportion) -> f64
 
fn from(portion: Proportion) -> f64
Converts to this type from the input type.
sourceimpl Hash for Proportion
 
impl Hash for Proportion
sourceimpl Ord for Proportion
 
impl Ord for Proportion
sourceimpl PartialEq<Proportion> for Proportion
 
impl PartialEq<Proportion> for Proportion
sourcefn eq(&self, other: &Proportion) -> bool
 
fn eq(&self, other: &Proportion) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &Proportion) -> bool
 
fn ne(&self, other: &Proportion) -> bool
This method tests for !=.
sourceimpl PartialOrd<Proportion> for Proportion
 
impl PartialOrd<Proportion> for Proportion
sourcefn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
 
fn partial_cmp(&self, other: &Proportion) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
 
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
 
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl Serialize for Proportion
 
impl Serialize for Proportion
sourceimpl TryFrom<f32> for Proportion
 
impl TryFrom<f32> for Proportion
sourceimpl TryFrom<f64> for Proportion
 
impl TryFrom<f64> for Proportion
impl Copy for Proportion
impl Eq for Proportion
impl StructuralEq for Proportion
impl StructuralPartialEq for Proportion
Auto Trait Implementations
impl RefUnwindSafe for Proportion
impl Send for Proportion
impl Sync for Proportion
impl Unpin for Proportion
impl UnwindSafe for Proportion
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
    T: Hash + ?Sized, 
 
impl<T> CallHasher for T where
    T: Hash + ?Sized, 
sourceimpl<T> CallHasher for T where
    T: Hash, 
 
impl<T> CallHasher for T where
    T: Hash, 
sourceimpl<Q, K> Equivalent<K> for Q where
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized, 
 
impl<Q, K> Equivalent<K> for Q where
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized, 
sourcefn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
 
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
 
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
 
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
 
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more