pub enum Keep {
Highest(u32),
Lowest(u32),
}Expand description
Specifies which dice to keep from a roll.
This enum is used with RollSpec to implement advantage/disadvantage
mechanics or other “keep best/worst N” scenarios.
§Variants
Highest(N): Keep the N highest dice from the rollLowest(N): Keep the N lowest dice from the roll
§Examples
use dice_parser::{DiceExpr, RollSpec, Keep};
// D&D 5e advantage: roll 2d20, keep highest 1
let advantage = RollSpec::new(2, 20, Some(Keep::Highest(1)));
let expr = DiceExpr::Roll(advantage);
// D&D ability scores: roll 4d6, keep highest 3
let ability_roll = RollSpec::new(4, 6, Some(Keep::Highest(3)));
let expr = DiceExpr::Roll(ability_roll);
// Keep the lowest roll (disadvantage)
let disadvantage = RollSpec::new(2, 20, Some(Keep::Lowest(1)));
let expr = DiceExpr::Roll(disadvantage);Variants§
Highest(u32)
Keep the N highest dice from the roll.
Lowest(u32)
Keep the N lowest dice from the roll.
Trait Implementations§
impl Eq for Keep
impl StructuralPartialEq for Keep
Auto Trait Implementations§
impl Freeze for Keep
impl RefUnwindSafe for Keep
impl Send for Keep
impl Sync for Keep
impl Unpin for Keep
impl UnwindSafe for Keep
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