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§
Source§impl Error for RollError
impl Error for RollError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn 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 Freeze for RollError
impl RefUnwindSafe for RollError
impl Send for RollError
impl Sync for RollError
impl Unpin for RollError
impl UnwindSafe for RollError
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