Expand description
§score-set
A #![no_std] + alloc Rust library for building weighted scoring
operators — define metrics via a builder pipeline, combine them into a
zero-vtable flat scorer with the score_set32! macro.
§Quick example
ⓘ
use score_set::*;
struct Restaurant {
cleanliness: f32,
food_quality: f32,
}
let clean = metric32("cleanliness")
.measure()
.by(|r: &Restaurant| r.cleanliness)
.map01()
.linear(100.0);
let food = metric32("food")
.measure()
.by(|r: &Restaurant| r.food_quality)
.map01()
.identity();
let scorer = score_set32! { 2.0 => clean, 1.0 => food }?;
let r = Restaurant { cleanliness: 80.0, food_quality: 4.0 };
let total: f32 = scorer.score(&r);
let rows = scorer.breakdown(&r);§Partial application
by() accepts capturing closures, enabling parameter
binding at construction time:
ⓘ
let threshold: f32 = 0.6;
let quality = metric32("quality")
.measure()
.by(move |ctx: &MyCtx| if ctx.value > threshold { ctx.value } else { 0.0 })
.map01()
.identity();
let scorer = score_set32! { 1.0 => quality }?;
// scorer only needs &MyCtx — threshold is baked in§no_std
This crate is #![no_std] with extern crate alloc — it only needs
Vec from the allocator and works on bare-metal targets.
Macros§
- score_
set32 - Combine heterogeneous metrics into a zero-vtable, zero-heap-allocation weighted scorer.
Structs§
- Breakdown32
- A single metric’s contribution to the total score.
- GtZero
- Witness credential for a value validated to be finite and strictly > 0.
- Map01
Stage32 - Waiting for a normalization strategy.
- Measure
Stage32 - Waiting for a measure function.
- Measured
Stage32 - Has a measure function, waiting for a
Map0132strategy. - Metric32
- A single named scoring metric with its normalization strategy.
- Metric
Naming Stage32 - Entry point for building a
Metric32. - Normalized
Container - Witness credential for a container validated as a complete set of
normalized weights (each in
[0, 1], sum to 1). - Normalized
Weight - Witness credential for a single normalized weight.
- Scored32
- A validated weighted scorer holding a flat tuple of
Metric32s. - Value01
- Witness credential for a value validated to be finite and in
[0, 1]. - Witnessed
Enums§
- Map0132
- Normalization strategy that maps a raw measure to
[0, 1].
Traits§
- Score
SetTrait32 - Trait implemented by tuples of
Metric32s for weighted evaluation. - Witness
Ext - Extension trait for starting a witnessing pipeline.
Functions§
- metric32
- Create a new metric with the given name.