pub struct Builder(/* private fields */);
Expand description
Builds Dice
with a fluent interface.
§Examples
§Basic dice
use tyche::Dice;
let dice = Dice::builder().count(2).sides(6).build();
assert_eq!(dice, Dice::new(2, 6));
§Single modifier
use tyche::dice::{Dice, Modifier};
let dice = Dice::builder().count(6).sides(8).explode(None, true).build();
assert_eq!(
dice,
Dice {
count: 6,
sides: 8,
modifiers: vec![Modifier::Explode {
cond: None,
recurse: true,
}],
},
);
§Multiple modifiers
use tyche::dice::{modifier::{Condition, Modifier}, Dice};
let dice = Dice::builder()
.count(6)
.sides(8)
.reroll(Condition::Eq(1), false)
.keep_high(4)
.build();
assert_eq!(
dice,
Dice {
count: 6,
sides: 8,
modifiers: vec![
Modifier::Reroll {
cond: Condition::Eq(1),
recurse: false
},
Modifier::KeepHigh(4),
],
},
);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
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