Enum die_parser::RollError
source · [−]pub enum RollError {
DieTypeInvalid,
DiceExceedLimit,
NoDiceToRoll,
ParsingError,
}
Expand description
The different types of errors that may occur trying to construct a Roll from a given input string.
Variants
DieTypeInvalid
Signifies that the inputted die type did not match any of the valid types.
Valid die types are: d2
, d4
, d6
, d8
, d10
, d12
, d20
, d100
Example
use die_parser::{Roll, RollError};
let invalid_roll = Roll::parse_roll("1d50");
assert_eq!(invalid_roll, Err(RollError::DieTypeInvalid));
DiceExceedLimit
Signifies that the requested amount of dice exceeded the set limit.
Example
use die_parser::{Roll, RollError};
let invalid_roll = Roll::parse_roll("9001d20");
assert_eq!(invalid_roll, Err(RollError::DiceExceedLimit));
NoDiceToRoll
Signifies that the requested amount of dice was less than 1.
Example
use die_parser::{Roll, RollError};
let invalid_roll = Roll::parse_roll("0d20");
assert_eq!(invalid_roll, Err(RollError::NoDiceToRoll));
ParsingError
Signifies that the input string was malformed.
Example
use die_parser::{Roll, RollError};
let invalid_roll = Roll::parse_roll("4invalid_charactersd20+5");
assert_eq!(invalid_roll, Err(RollError::ParsingError));
Trait Implementations
sourceimpl Error for RollError
impl Error for RollError
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
🔬 This is a nightly-only experimental API. (
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
👎 Deprecated since 1.42.0:
use the Display impl or to_string()
impl StructuralPartialEq for RollError
Auto Trait Implementations
impl RefUnwindSafe for RollError
impl Send for RollError
impl Sync for RollError
impl Unpin for RollError
impl UnwindSafe for RollError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more