[−][src]Enum critfail::RollOutcome
The outcome of rolling a check, damage, or attack roll.
This is normally constructed as the result of calling roll()
on a
Roll
roll expression.
A RollOutcome
can be printed with Display
and Debug
, but if
you need more information about the result you will need to
destructure the enum and handle the different types individually.
use critfail::{RollExpression, Roll, RollOutcome}; let check: RollOutcome = Roll::new("r+6").unwrap().roll(); let damage: RollOutcome = Roll::new("4d4+6").unwrap().roll(); let attack: RollOutcome = Roll::new("r+3?2d8+3").unwrap().roll(); fn print_score(outcome: RollOutcome) { match outcome { RollOutcome::Check(check) => println!("Check score: {}", check.score()), RollOutcome::Damage(damage) => println!("Damage score: {}", damage.score()), RollOutcome::Attack(attack) => { println!("Check score: {}", attack.check().score()); println!("Damage score: {}", attack.damage().score()) } } } print_score(check); print_score(damage); print_score(attack);
Variants
Check(CheckOutcome)
The outcome of a Roll
that contained a Check
.
Damage(DamageOutcome)
The outcome of a Roll
that contained a Damage
.
Attack(AttackOutcome)
The outcome of a Roll
that contained an Attack
.
Implementations
impl RollOutcome
[src]
pub fn is_check(&self) -> bool
[src]
Return true if this RollOutcome
is the outcome of a check roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().roll().is_check(), true); assert_eq!(Roll::new("2d8+5").unwrap().roll().is_check(), false); assert_eq!(Roll::new("r+3?2d8+5").unwrap().roll().is_check(), false);
pub fn is_damage(&self) -> bool
[src]
Return true if this RollOutcome
is the outcome of a damage roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().roll().is_damage(), false); assert_eq!(Roll::new("2d8+5").unwrap().roll().is_damage(), true); assert_eq!(Roll::new("r+3?2d8+5").unwrap().roll().is_damage(), false);
pub fn is_attack(&self) -> bool
[src]
Return true if this RollOutcome
is the outcome of an attack roll.
use critfail::{RollExpression, Roll}; assert_eq!(Roll::new("r+3").unwrap().roll().is_attack(), false); assert_eq!(Roll::new("2d8+5").unwrap().roll().is_attack(), false); assert_eq!(Roll::new("r+3?2d8+5").unwrap().roll().is_attack(), true);
Trait Implementations
impl Clone for RollOutcome
[src]
fn clone(&self) -> RollOutcome
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RollOutcome
[src]
impl Display for RollOutcome
[src]
impl From<AttackOutcome> for RollOutcome
[src]
fn from(o: AttackOutcome) -> Self
[src]
impl From<CheckOutcome> for RollOutcome
[src]
fn from(o: CheckOutcome) -> Self
[src]
impl From<DamageOutcome> for RollOutcome
[src]
fn from(o: DamageOutcome) -> Self
[src]
Auto Trait Implementations
impl RefUnwindSafe for RollOutcome
impl Send for RollOutcome
impl Sync for RollOutcome
impl Unpin for RollOutcome
impl UnwindSafe for RollOutcome
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,