[−][src]Struct imdb_index::Scored
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]
pub fn new(value: T) -> Scored<T>
[src]
Create a new value T
with a score of 1.0
.
pub fn score(&self) -> f64
[src]
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]
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]
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]
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]
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]
Return a reference to the underlying value.
pub fn into_value(self) -> T
[src]
Consume this scored value, drop the score and return the underlying
T
.
pub fn into_pair(self) -> (f64, T)
[src]
Consume this scored value and return the underlying pair of score and
T
.
Trait Implementations
impl<T> PartialOrd<Scored<T>> for Scored<T>
[src]
fn partial_cmp(&self, other: &Scored<T>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> PartialEq<Scored<T>> for Scored<T>
[src]
fn eq(&self, other: &Scored<T>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: Copy> Copy for Scored<T>
[src]
impl<T> Ord for Scored<T>
[src]
fn cmp(&self, other: &Scored<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl<T> Eq for Scored<T>
[src]
impl<T: Default> Default for Scored<T>
[src]
impl<T: Clone> Clone for Scored<T>
[src]
fn clone(&self) -> Scored<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Scored<T>
[src]
Auto Trait Implementations
impl<T> Send for Scored<T> where
T: Send,
T: Send,
impl<T> Unpin for Scored<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for Scored<T> where
T: Sync,
T: Sync,
impl<T> UnwindSafe for Scored<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Scored<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,