pub enum WeightedStore<T> {
Values(Vec<WeightedValue<T>>),
NoValue {
message: String,
},
}Expand description
A weighted value store for a single weighted property.
Held only for the genuinely weighted properties (CountryCodesGeographical,
CountryCodesPopulation, Mcc). It mirrors the two states of an
AspectPropertyValue: an ordered list of weighted candidates, or a
no-value message. The list is held high weighting first; the constructor
sorts it for you.
Variants§
Values(Vec<WeightedValue<T>>)
One or more weighted candidate values, ordered high weighting first.
NoValue
No value could be determined. The message explains why.
Implementations§
Source§impl<T> WeightedStore<T>
impl<T> WeightedStore<T>
Sourcepub fn values(list: Vec<WeightedValue<T>>) -> Self
pub fn values(list: Vec<WeightedValue<T>>) -> Self
Build a store from a list of weighted candidates, sorting it high weighting first.
An empty list is stored as the WeightedStore::Values variant (an
empty distribution), not as a no-value. Use WeightedStore::no_value
when the engine could determine nothing.
Sourcepub fn no_value(message: impl Into<String>) -> Self
pub fn no_value(message: impl Into<String>) -> Self
Build a no-value store carrying the supplied explanatory message.
Sourcepub fn list(&self) -> Result<&[WeightedValue<T>], NoValueError>
pub fn list(&self) -> Result<&[WeightedValue<T>], NoValueError>
Borrow the weighted list, or Err(NoValueError) carrying the stored
message if this is a no-value.
Trait Implementations§
Source§impl<T: Clone> Clone for WeightedStore<T>
impl<T: Clone> Clone for WeightedStore<T>
Source§fn clone(&self) -> WeightedStore<T>
fn clone(&self) -> WeightedStore<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more