store : validation : check dices

This commit is contained in:
Henri Bourcereau 2024-02-03 22:16:14 +01:00
parent 41647ebd1b
commit 8c99b228d3
2 changed files with 90 additions and 24 deletions

View file

@ -19,9 +19,7 @@ impl Dices {
let v = (between.sample(&mut rng), between.sample(&mut rng));
Dices {
values: (v.0, v.1),
}
Dices { values: (v.0, v.1) }
}
/// Heads or tails
@ -31,7 +29,6 @@ impl Dices {
between.sample(&mut rng) == 1
}
pub fn to_bits_string(self) -> String {
format!("{:0>3b}{:0>3b}", self.values.0, self.values.1)
}
@ -51,7 +48,7 @@ impl Dices {
/// Trait to roll the dices
pub trait Roll {
/// Roll the dices
fn roll(&mut self) -> Result<&mut Self, Error>;
fn roll(&mut self) -> &mut Self;
}
#[cfg(test)]
@ -67,8 +64,7 @@ mod tests {
#[test]
fn test_to_bits_string() {
let dices = Dices { values: (4, 2)};
let dices = Dices { values: (4, 2) };
assert!(dices.to_bits_string() == "100010");
}
}