Skip to main content

Score

Struct Score 

Source
pub struct Score { /* private fields */ }
Expand description

A score for Benchmark::try_match.

A Score is in one of two states: success or failure. Lower scores indicate better matches in both states. In the failure case, scores rank “near misses” for diagnostics.

The current state can be queried with Score::is_success.

Implementations§

Source§

impl Score

Source

pub fn penalize(&mut self, by: u32)

If the score is in the “success” state, penalize it by by.

Has no effect if the score is already in the “failure” state.

Source

pub fn fail(&mut self, by: u32, reason: &dyn Display)

Transition the score to the “failure” state with penalty by and a reason.

If the score is already in the “failure” state, by is added to the existing failure score and reason is appended to the list of failure reasons.

Source

pub fn is_success(&self) -> bool

Return true if self is in the “success” state. Returning false implies the “failure” state.

Trait Implementations§

Source§

impl Debug for Score

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Score

§

impl RefUnwindSafe for Score

§

impl Send for Score

§

impl Sync for Score

§

impl Unpin for Score

§

impl UnsafeUnpin for Score

§

impl UnwindSafe for Score

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.