Skip to main content

Metric

Struct Metric 

Source
pub struct Metric<T, I, Raw, M, F> { /* private fields */ }
Expand description

A scoring operator built via the measure().by() → map01().by() pipeline.

Stores two closures:

  • measure: Fn(I) -> Raw — maps input to an intermediate raw value.
  • map01: Fn(&Raw, I) -> Witnessed<T, Value01> — maps the raw value back alongside the original input to a validated [0, 1] score.

eval(input) composes the two closures.

Implementations§

Source§

impl<T: Float, I, Raw, M, F> Metric<T, I, Raw, M, F>
where M: Fn(&I) -> Raw, F: Fn(&Raw, &I) -> Witnessed<T, Value01>,

Source

pub fn eval(&self, input: &I) -> Witnessed<T, Value01>

Evaluate this metric against an input, producing a [0, 1] score.

Source

pub fn name(&self) -> &str

Return the metric’s name.

Source§

impl<T: Float, I: 'static, Raw: 'static, M, F> Metric<T, I, Raw, M, F>
where M: Fn(&I) -> Raw + 'static, F: Fn(&Raw, &I) -> Witnessed<T, Value01> + 'static,

Source

pub fn boxed(self) -> Box<dyn Scorable<T, I>>

Box this metric as a Box<dyn Scorable<T, I>> for use in DynamicScoreSet.

This is a convenience over Box::new(metric) — it infers the Scorable type automatically, avoiding an explicit annotation.

Trait Implementations§

Source§

impl<T, I, Raw, M: Clone, F: Clone> Clone for Metric<T, I, Raw, M, F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, I, Raw, M, F> Scorable<T, I> for Metric<T, I, Raw, M, F>
where T: Float, M: Fn(&I) -> Raw, F: Fn(&Raw, &I) -> Witnessed<T, Value01>,

Source§

fn eval(&self, input: &I) -> Witnessed<T, Value01>

Evaluate this metric against an input, producing a [0, 1] score.
Source§

fn name(&self) -> &str

Return the metric’s name.

Auto Trait Implementations§

§

impl<T, I, Raw, M, F> Freeze for Metric<T, I, Raw, M, F>
where M: Freeze, F: Freeze,

§

impl<T, I, Raw, M, F> RefUnwindSafe for Metric<T, I, Raw, M, F>

§

impl<T, I, Raw, M, F> Send for Metric<T, I, Raw, M, F>
where M: Send, F: Send, T: Send, I: Send, Raw: Send,

§

impl<T, I, Raw, M, F> Sync for Metric<T, I, Raw, M, F>
where M: Sync, F: Sync, T: Sync, I: Sync, Raw: Sync,

§

impl<T, I, Raw, M, F> Unpin for Metric<T, I, Raw, M, F>
where M: Unpin, F: Unpin, T: Unpin, I: Unpin, Raw: Unpin,

§

impl<T, I, Raw, M, F> UnsafeUnpin for Metric<T, I, Raw, M, F>
where M: UnsafeUnpin, F: UnsafeUnpin,

§

impl<T, I, Raw, M, F> UnwindSafe for Metric<T, I, Raw, M, F>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WitnessExt for T

Source§

fn witness(self) -> Witnessing<Self>