diff options
Diffstat (limited to 'src/dice.rs')
-rw-r--r-- | src/dice.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/dice.rs b/src/dice.rs index 64a4635..2c778f4 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -1,6 +1,6 @@ +use rand::Rng; use std::fmt; use std::fmt::Formatter; -use rand::Rng; pub struct DieRoll { sides: u32, @@ -9,10 +9,7 @@ pub struct DieRoll { impl DieRoll { fn new(sides: u32, face: u32) -> Self { - DieRoll { - sides, - face, - } + DieRoll { sides, face } } } @@ -22,9 +19,7 @@ pub struct RollResult { impl RollResult { pub fn new() -> Self { - RollResult { - rolls: Vec::new(), - } + RollResult { rolls: Vec::new() } } fn add_roll(&mut self, roll: DieRoll) { @@ -38,10 +33,16 @@ impl RollResult { impl fmt::Display for RollResult { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "{} ({})", self.total(), self.rolls.iter() - .map(|dr| dr.face.to_string()) - .collect::<Vec<String>>() - .join(", ")) + write!( + f, + "{} ({})", + self.total(), + self.rolls + .iter() + .map(|dr| dr.face.to_string()) + .collect::<Vec<String>>() + .join(", ") + ) } } |