Skip to main content

Metric32

Struct Metric32 

Source
pub struct Metric32<C, F = fn(&C) -> f32> {
    pub name: &'static str,
    /* private fields */
}
Expand description

A single named scoring metric with its normalization strategy.

Metric32<C, F> combines a measure closure F: Fn(&C) -> f32 with a Map0132 normalization. The default F = fn(&C) -> f32 keeps backward compatibility for fn-pointer metrics used with [ScoreSet32].

Use capturing closures for partial application (e.g. thresholds, config parameters), then combine heterogeneous metrics via the [score_set32!] macro.

Fields§

§name: &'static str

Human-readable name for this metric.

Implementations§

Source§

impl<C, F: Fn(&C) -> f32> Metric32<C, F>

Source

pub fn eval(&self, ctx: &C) -> Result<Witnessed<f32, Value01>, &'static str>

Evaluate this metric against a context.

Returns the normalized score in [0, 1], witnessed by Value01.

Source

pub fn make_breakdown(&self, weight: f32, ctx: &C) -> Breakdown32

Produce a single Breakdown32 row for this metric.

Evaluates the measure closure and normalization against ctx, then packs the result together with the given weight into a breakdown row.

This is pub (not pub(crate)) because the #[macro_export] [score_set32!] macro expands in the caller’s crate — $crate items must be fully public to be accessible across crate boundaries.

Trait Implementations§

Source§

impl<C, F: Clone> Clone for Metric32<C, 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

Auto Trait Implementations§

§

impl<C, F> Freeze for Metric32<C, F>
where F: Freeze,

§

impl<C, F> RefUnwindSafe for Metric32<C, F>
where F: RefUnwindSafe,

§

impl<C, F> Send for Metric32<C, F>
where F: Send,

§

impl<C, F> Sync for Metric32<C, F>
where F: Sync,

§

impl<C, F> Unpin for Metric32<C, F>
where F: Unpin,

§

impl<C, F> UnsafeUnpin for Metric32<C, F>
where F: UnsafeUnpin,

§

impl<C, F> UnwindSafe for Metric32<C, F>
where F: UnwindSafe,

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>