pub struct Distribution { /* private fields */ }
Expand description
The chances for a specific situation for each camel.
Implementations§
Source§impl Distribution
impl Distribution
Sourcepub fn values(&self) -> impl Iterator<Item = (&Camel, &Fraction)> + '_
pub fn values(&self) -> impl Iterator<Item = (&Camel, &Fraction)> + '_
Returns an iterator that iterates over the chances.
I.e. iterates over (&Camel, &Fraction)
values.
Examples found in repository?
examples/who.rs (line 11)
5fn main() {
6 let race = "r,,y".parse::<Race>().expect("to parse");
7 let dice = "ry".parse::<Dice>().expect("to parse");
8
9 let result = project(&race, &dice);
10 let mut ordered: Vec<(Camel, Fraction)> =
11 result.winner.values().map(|(k, v)| (*k, *v)).collect();
12 ordered.sort_by(|(_, left), (_, right)| right.cmp(&left));
13 for (camel, fraction) in ordered {
14 print!("({:?},{})", camel, fraction);
15 }
16 println!();
17}
More examples
examples/tower.rs (line 11)
5fn main() {
6 let race = "gyor,,,w".parse::<Race>().expect("to parse");
7 let dice = "gyorw".parse::<Dice>().expect("to parse");
8
9 let result = project(&race, &dice);
10 let mut ordered: Vec<(Camel, Fraction)> =
11 result.winner.values().map(|(k, v)| (*k, *v)).collect();
12 ordered.sort_by(|(_, left), (_, right)| right.cmp(&left));
13 for (camel, fraction) in ordered {
14 print!("({:?},{})", camel, fraction);
15 }
16 println!()
17}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Distribution
impl RefUnwindSafe for Distribution
impl Send for Distribution
impl Sync for Distribution
impl Unpin for Distribution
impl UnwindSafe for Distribution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more