1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # 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.
//!
//! ```
//! # fn main() {
//! #     if let Err(_) = run() { ::std::process::exit(1) }
//! # }
//! #
//! # fn run() -> Result<(), Box<dyn std::error::Error>> {
//! 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());
//! # Ok(())
//! # }
//! ```
//! [`treys`]: https://github.com/ihendley/treys

#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![doc(html_root_url = "https://docs.rs/poker/0.3")]

#[cfg(doctest)]
doc_comment::doctest!("../README.md");

pub mod card;
mod constants;
pub mod error;
pub mod evaluate;
mod ext;

#[doc(inline)]
pub use card::{Card, Rank, Suit};
#[doc(inline)]
pub use error::{EvalError, ParseCardError};
#[doc(inline)]
pub use evaluate::{Eval, EvalClass, Evaluator};