[][src]Struct imdb_index::Scored

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]

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]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.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) -> bool1.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) -> bool1.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) -> bool1.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]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T: Copy> Copy for Scored<T>[src]

impl<T> Ord for Scored<T>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (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_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

impl<T> Unpin for Scored<T> where
    T: Unpin

impl<T> Sync for Scored<T> where
    T: Sync

impl<T> UnwindSafe for Scored<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for Scored<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]