Skip to main content

DynamicScoreSetBuilder

Struct DynamicScoreSetBuilder 

Source
pub struct DynamicScoreSetBuilder<T: Float, I> { /* private fields */ }
Expand description

Incremental builder for DynamicScoreSet.

Accumulates raw (weight, metric) pairs via .push(), then normalizes them into a DynamicScoreSet via .build().

Each weight is validated on push (must be finite and > 0). Normalization happens once at build time.

§Examples

Chain construction:

let set = DynamicScoreSet::<f64, &str>::builder()
    .push(2.0, gc_metric.boxed())?
    .push(3.0, len_metric.boxed())?
    .build()?;

Conditional construction:

let mut builder = DynamicScoreSet::<f64, &str>::builder();
builder = builder.push(2.0, baseline_metric.boxed())?;
if enable_extra {
    builder = builder.push(1.0, extra_metric.boxed())?;
}
let set = builder.build()?;

Implementations§

Source§

impl<T: Float, I> DynamicScoreSetBuilder<T, I>

Source

pub fn push( self, weight: T, metric: Box<dyn Scorable<T, I>>, ) -> Result<Self, &'static str>

Push a metric with a raw weight into the builder.

The weight must be finite and strictly positive. This is validated immediately (fail-fast). Takes and returns Self for chaining.

For incremental construction, rebind the result:

let mut builder = DynamicScoreSet::builder();
builder = builder.push(2.0, gc_metric.boxed())?;
if some_condition {
    builder = builder.push(1.0, extra_metric.boxed())?;
}
let set = builder.build()?;
§Errors

Returns an error if weight is zero, negative, or not finite.

Source

pub fn build(self) -> Result<DynamicScoreSet<T, I>, &'static str>

Consume the builder and produce a DynamicScoreSet with normalized weights.

§Errors

Returns an error if no members were pushed.

Auto Trait Implementations§

§

impl<T, I> !RefUnwindSafe for DynamicScoreSetBuilder<T, I>

§

impl<T, I> !Send for DynamicScoreSetBuilder<T, I>

§

impl<T, I> !Sync for DynamicScoreSetBuilder<T, I>

§

impl<T, I> !UnwindSafe for DynamicScoreSetBuilder<T, I>

§

impl<T, I> Freeze for DynamicScoreSetBuilder<T, I>

§

impl<T, I> Unpin for DynamicScoreSetBuilder<T, I>
where T: Unpin,

§

impl<T, I> UnsafeUnpin for DynamicScoreSetBuilder<T, I>

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> 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, 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>