Enum poker::EvalError[][src]

pub enum EvalError {
    CardsNotUnique(Vec<Card>),
    InvalidHandSize(usize),
}

An error that can be thrown when evaluating poker hands.

Examples

If a group of Cards to be evaluated does not contain a set of unique cards, EvalError::CardsNotUnique will be thrown, as shown below:

use poker::{cards, Evaluator, EvalError};
let eval = Evaluator::new();
// Two king of clubs instead of a royal flush!
let hand = cards!(
    Ten, Clubs;
    Jack, Clubs;
    Queen, Clubs;
    King, Clubs;
    King, Clubs
).to_vec();
let result = eval.evaluate(&hand);
assert_eq!(
    result,
    Err(EvalError::CardsNotUnique(hand.clone()))
);

A group of 5 or more cards can be evaulated for the combination that yields the best possible poker hand, but four of less cards cannot be evaluated. This will throw EvalError::InvalidHandSize:

use poker::{cards, Evaluator, EvalError};
let eval = Evaluator::new();
let four_cards = cards!(
    Two, Clubs;
    Ten, Hearts;
    Seven, Hearts;
    Eight, Spades;
).to_vec();
let result = eval.evaluate(&four_cards);
assert_eq!(
    result,
    Err(EvalError::InvalidHandSize(4)),
);

Variants

CardsNotUnique(Vec<Card>)

This variant is used when the cards to be evaluated are not all unique. This captures the entire original hand, and the duplicates are calculated when reporting in Display format.

InvalidHandSize(usize)

This variant is used when the cards to be evaluated total to 4 or less.

Trait Implementations

impl Clone for EvalError[src]

impl Debug for EvalError[src]

impl Display for EvalError[src]

impl Eq for EvalError[src]

impl Error for EvalError[src]

impl PartialEq<EvalError> for EvalError[src]

impl StructuralEq for EvalError[src]

impl StructuralPartialEq for EvalError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,