pub struct ScoreSet32<C> { /* private fields */ }Expand description
Builder for a weighted set of Metric32s.
ScoreSet32 collects metrics with raw weights, normalizes them, and produces
a closure — either a weighted-sum function or a breakdown iterator.
§Examples
let scorer = ScoreSet32::new()
.push(2.0, gc_metric)?
.push(1.0, len_metric)?
.sum()?;
let total: f32 = scorer(&ctx);Implementations§
Source§impl<C> ScoreSet32<C>
impl<C> ScoreSet32<C>
Sourcepub fn sum(self) -> Result<impl Fn(&C) -> f32, &'static str>
pub fn sum(self) -> Result<impl Fn(&C) -> f32, &'static str>
Consume the builder and return a weighted-sum closure.
Normalizes all weights so they sum to 1, then returns a closure
impl Fn(&C) -> f32 that evaluates every metric against the context
and returns the weighted sum.
§Errors
Returns an error if the set is empty or if weight normalization fails.
Sourcepub fn breakdown(
self,
ctx: &C,
) -> Result<impl IntoIterator<Item = Breakdown32>, &'static str>
pub fn breakdown( self, ctx: &C, ) -> Result<impl IntoIterator<Item = Breakdown32>, &'static str>
Consume the builder and return per-metric Breakdown32 rows.
Normalizes all weights so they sum to 1, evaluates every metric
against ctx, and returns the result as impl IntoIterator. The
returned value owns all data — no lifetime coupling to ctx — so
it can be passed out of local scopes freely.
Use directly in a for loop or call .into_iter().
§Errors
Returns an error if the set is empty or if weight normalization fails.