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 strHuman-readable name for this metric.
Implementations§
Source§impl<C, F: Fn(&C) -> f32> Metric32<C, F>
impl<C, F: Fn(&C) -> f32> Metric32<C, F>
Sourcepub fn eval(&self, ctx: &C) -> Result<Witnessed<f32, Value01>, &'static str>
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.
Sourcepub fn make_breakdown(&self, weight: f32, ctx: &C) -> Breakdown32
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.