pub struct Scored<T> { /* private fields */ }Expand description
Any value associated with a score.
We define Eq and Ord on this type in a way that ignores value and only
uses the score to determine ordering. The public API of Scored
guarantees that scores are never NaN.
Implementations§
Source§impl<T> Scored<T>
impl<T> Scored<T>
Sourcepub fn score(&self) -> f64
pub fn score(&self) -> f64
Return the score for this item.
In general, no restrictions are placed on the range of scores, however
most search APIs that use it will return scores in the range [0, 1].
The score returned is guaranteed to never be NaN.
Sourcepub fn set_score(&mut self, score: f64)
pub fn set_score(&mut self, score: f64)
Set the score, replacing the existing value with the given value.
This panics if the given score is NaN.
Sourcepub fn with_score(self, score: f64) -> Scored<T>
pub fn with_score(self, score: f64) -> Scored<T>
Consume this scored value and return a new scored value that drops the existing score and replaces it with the given score.
This panics if the given score is NaN.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Scored<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Scored<U>
Consume this scored value and map its value using the function given, returning a new scored value with the result of the map and an unchanged score.
Sourcepub fn map_score<F: FnOnce(f64) -> f64>(self, f: F) -> Scored<T>
pub fn map_score<F: FnOnce(f64) -> f64>(self, f: F) -> Scored<T>
Consume this scored value and map its score using the function given,
return a new Scored with an unchanged value.
This panics if score returned by f is NaN.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Consume this scored value, drop the score and return the underlying
T.