version = "0.1.0"
edition = "2021"
+[lib]
+crate-type = ["cdylib", "rlib"]
+
[features]
parallel = ["rayon"]
[dependencies]
rayon = { version = "1.5.1", optional = true }
+wasm-bindgen = "0.2.78"
Poker hand evaluator
-Based on Kevin L. Suffecool poker hand evaluator.
-<http://suffe.cool/poker/evaluator.html>
+This project can be built using wasm-pack.\
+An example is available [here](https://poker-eval.beaudet.xyz).
+
+Based on Kevin L. Suffecool [poker hand evaluator](http://suffe.cool/poker/evaluator.html)
PERM7, PRIMES, STRAIGHT, STRAIGHT_FLUSH, THREE_OF_A_KIND, TWO_PAIR, UNIQUE5,
};
+use wasm_bindgen::prelude::*;
+
/// Initializes a deck of 52 cards as an integer vector of lenght 52.
///
/// The order in which the cards are returned is not random.
/// assert_eq!(eval_from_str("4s 4d 4h 4c 5d"), 140);
/// assert_eq!(eval_from_str("Ts 9s 8s 7s 6s 7h 6d"), 5);
/// ```
+#[wasm_bindgen]
pub fn eval_from_str(s: &str) -> u32 {
let cards = s.split(' ').map(|c| card_from_str(c)).collect::<Vec<_>>();
match cards.len() {
/// assert_eq!(eval, 1433);
/// assert_eq!(hand_rank(eval), FLUSH);
/// ```
+#[wasm_bindgen]
pub fn hand_rank(i: u32) -> u32 {
match i {
6186..=7462 => HIGH_CARD,