choose
Picks one element at random, each with the same probability.
Import
Section titled “Import”Cargo feature random (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
items | &'a [T] | The elements to pick from. |
rng | &mut Rng | The generator that decides the pick. |
Returns
Section titled “Returns”Option<&'a T> — A reference to the chosen element, or None when items is empty.
