pub trait Scorable<T: Float, I> {
// Required methods
fn eval(&self, input: &I) -> Witnessed<T, Value01>;
fn name(&self) -> &str;
}Expand description
A type-erased metric that can be evaluated against input I.
This trait enables dynamic dispatch over heterogeneous metric types via
Box<dyn Scorable<T, I>>. It is the core abstraction behind
DynamicScoreSet.
Any Metric can be converted into a
Box<dyn Scorable<T, I>> through the blanket implementation.
§Examples
ⓘ
use score_set::*;
let gc = metric("gc")
.measure().by(|dna: &&str| gc_ratio(dna))
.map01().by(|raw: &f64, _: &&str| Value01::witness(*raw).unwrap());
let dyn_metric: Box<dyn Scorable<f64, &str>> = Box::new(gc);
assert_eq!(dyn_metric.name(), "gc");
let score = dyn_metric.eval(&"ACGT");Required Methods§
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".