logo
pub struct WeightedChoice<'a, T: 'a> { /* private fields */ }
👎 Deprecated since 0.6.0:

use WeightedIndex instead

Expand description

A distribution that selects from a finite collection of weighted items.

Deprecated: use WeightedIndex instead.

Implementations

👎 Deprecated since 0.6.0:

use WeightedIndex instead

Create a new WeightedChoice.

Panics if:

  • items is empty
  • the total weight is 0
  • the total weight is larger than a u32 can contain.

Trait Implementations

Formats the value using the given formatter. Read more

Generate a random value of T, using rng as the source of randomness.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.