Skip to main content

populate_from_source

Function populate_from_source 

Source
pub fn populate_from_source<A, W, I>(
    framework: &mut WeightedFramework<A>,
    pairs: I,
    source: &W,
) -> Result<(), Error>
where A: Clone + Eq + Hash, W: WeightSource<A>, I: IntoIterator<Item = (A, A)>,
Expand description

Populate a WeightedFramework from a list of attack pairs, pulling each weight from the provided WeightSource. Pairs for which the source returns None are skipped. Pairs for which the source returns an invalid weight propagate an Error::InvalidWeight.

This is a convenience builder. Consumers that need more control (e.g., different sources for different attack types) should call add_weighted_attack directly.