Struct imdb_index::Scored [−][src]
pub struct Scored<T> { /* fields omitted */ }
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
.
Methods
impl<T> Scored<T>
[src]
impl<T> Scored<T>
pub fn new(value: T) -> Scored<T>
[src]
pub fn new(value: T) -> Scored<T>
Create a new value T
with a score of 1.0
.
pub fn score(&self) -> f64
[src]
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
.
pub fn set_score(&mut self, score: f64)
[src]
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
.
pub fn with_score(self, score: f64) -> Scored<T>
[src]
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
.
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Scored<U>
[src]
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.
pub fn map_score<F: FnOnce(f64) -> f64>(self, f: F) -> Scored<T>
[src]
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
.
pub fn value(&self) -> &T
[src]
pub fn value(&self) -> &T
Return a reference to the underlying value.
pub fn into_value(self) -> T
[src]
pub fn into_value(self) -> T
Consume this scored value, drop the score and return the underlying
T
.
pub fn into_pair(self) -> (f64, T)
[src]
pub fn into_pair(self) -> (f64, T)
Consume this scored value and return the underlying pair of score and
T
.
Trait Implementations
impl<T: Clone> Clone for Scored<T>
[src]
impl<T: Clone> Clone for Scored<T>
fn clone(&self) -> Scored<T>
[src]
fn clone(&self) -> Scored<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Copy> Copy for Scored<T>
[src]
impl<T: Copy> Copy for Scored<T>
impl<T: Debug> Debug for Scored<T>
[src]
impl<T: Debug> Debug for Scored<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Default> Default for Scored<T>
[src]
impl<T: Default> Default for Scored<T>
impl<T> Eq for Scored<T>
[src]
impl<T> Eq for Scored<T>
impl<T> PartialEq for Scored<T>
[src]
impl<T> PartialEq for Scored<T>
fn eq(&self, other: &Scored<T>) -> bool
[src]
fn eq(&self, other: &Scored<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T> Ord for Scored<T>
[src]
impl<T> Ord for Scored<T>
fn cmp(&self, other: &Scored<T>) -> Ordering
[src]
fn cmp(&self, other: &Scored<T>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T> PartialOrd for Scored<T>
[src]
impl<T> PartialOrd for Scored<T>
fn partial_cmp(&self, other: &Scored<T>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Scored<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
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
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more