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 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
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef
].