Enum poker::ParseCardError [−][src]
pub enum ParseCardError { InvalidLength { original_input: String, }, InvalidRank { original_input: String, incorrect_char: char, }, InvalidSuit { original_input: String, incorrect_char: char, }, }
An error than can be thrown when parsing Card
types from strings.
Examples
An input with invalid length yields ParseCardError::InvalidLength
.
use poker::{Card, ParseCardError}; let ten_of_clubs = "10c"; // not two characters; use 'T' instead of '10'! let result = ten_of_clubs.parse::<Card>(); assert_eq!( result, Err(ParseCardError::InvalidLength { original_input: "10c".into() }) );
If an input is two characters, ParseCardError::InvalidRank
will be
thrown if the first character, representing the card’s rank, is not one of
‘23456789TJQKA’.
use poker::{Card, ParseCardError}; let jack_of_clubs = "jc"; let result = jack_of_clubs.parse::<Card>(); assert_eq!( result, Err(ParseCardError::InvalidRank { original_input: "jc".into(), incorrect_char: 'j' }) );
Similarly, a two-character input, with a second character representing the
suit, does not contain one of “chsd”, ParseCardError::InvalidSuit
will
be thrown.
use poker::{Card, ParseCardError}; let two_of_diamonds = "2D"; let result = two_of_diamonds.parse::<Card>(); assert_eq!( result, Err(ParseCardError::InvalidSuit { original_input: "2D".into(), incorrect_char: 'D' }) );
Variants
A string to be interpreted as a Card
must be exactly two characters
long. This variant is used if the input does not have meet this
criterion.
Show fields
A string to be interpreted as a Card
must have its first character
be one of “23456789TJQKA”, otherwise, this error will be thrown and
indicate the incorrect character.
Show fields
A string to be interpreted as a Card
must have its first character
be one of “23456789TJQKA”, otherwise, this error will be thrown and
indicate the incorrect character.
Show fields
Trait Implementations
impl Clone for ParseCardError
[src]
fn clone(&self) -> ParseCardError
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ParseCardError
[src]
impl Display for ParseCardError
[src]
impl Eq for ParseCardError
[src]
impl Error for ParseCardError
[src]
pub fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl PartialEq<ParseCardError> for ParseCardError
[src]
fn eq(&self, other: &ParseCardError) -> bool
[src]
fn ne(&self, other: &ParseCardError) -> bool
[src]
impl StructuralEq for ParseCardError
[src]
impl StructuralPartialEq for ParseCardError
[src]
Auto Trait Implementations
impl RefUnwindSafe for ParseCardError
impl Send for ParseCardError
impl Sync for ParseCardError
impl Unpin for ParseCardError
impl UnwindSafe for ParseCardError
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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.
pub 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>,