Crate poker[−][src]
Poker
poker
is a crate for efficient poker hand evaluation ported into Rust from
the treys
Python package. This packages introduces the algorithms that
are vital for speedy evaluation, which have been added on to or made more
idiomatic for Rust where appropriate.
use poker::{cards, Card, EvalClass, Evaluator, Rank}; // Create a reusable evaluator let eval = Evaluator::new(); // Parse a `Vec` of cards from a str let cards: Vec<Card> = cards!("Ks Js Ts Qs As").try_collect()?; // Evaluate the hand let hand = eval.evaluate(cards)?; assert!(matches!( hand.class(), EvalClass::StraightFlush { high_rank: Rank::Ace } )); assert!(hand.is_royal_flush());
Modules
card | Create and manage poker cards with suits and ranks. |
error | Two different error types that may be encountered when trying to parse
|
evaluate | Anything and everything about evaluating poker hands. |
Macros
box_cards | Use this macro to chain two or more slices of |
card | A utility macro for creating a single card. |
cards | A utility macro for creating multiple cards. |
Structs
Card | A single playing card. |
Eval | The result of a successful poker hand evaluation. When printed in
|
Evaluator | This structure does all the heavy lifting of evaluating poker hands. |
Enums
EvalClass | A utility enumeration type for pattern matching against the result of
|
EvalError | An error that can be thrown when evaluating poker hands. |
ParseCardError | An error than can be thrown when parsing |
Rank | An enumeration type for representing the thirteen card ranks, from two to ace. |
Suit | An enumeration type for representing the four card suits. |