26 releases

0.5.0 Dec 17, 2023
0.4.20 Oct 3, 2023
0.4.19 Jun 11, 2023
0.4.17 Mar 11, 2023
0.3.8 Oct 12, 2020

#83 in Game dev

Download history 26/week @ 2023-11-06 34/week @ 2023-11-13 40/week @ 2023-11-20 201/week @ 2023-11-27 76/week @ 2023-12-04 61/week @ 2023-12-11 79/week @ 2023-12-18 91/week @ 2023-12-25 6/week @ 2024-01-01 41/week @ 2024-01-08 10/week @ 2024-01-15 26/week @ 2024-01-22 113/week @ 2024-01-29 11/week @ 2024-02-05 96/week @ 2024-02-12 734/week @ 2024-02-19

955 downloads per month
Used in 2 crates


3.5K SLoC


License: Apache 2.0 Build and Test Crates.io Version Rustdocs

Generic pack of cards library written in Rust. The goals of the library include:

  • Various types of decks of cards.
  • Internationalization support.
  • Ability to create custom sorts for a specific pack of cards.


fn main() {
    let pack = cardpack::Pack::french_deck();

    let mut shuffled = pack.cards().shuffle();
    let sb = shuffled.draw(2).unwrap();
    let bb = shuffled.draw(2).unwrap();

    println!("small blind: {}", sb.by_symbol_index());
    println!("big blind:   {}", bb.by_symbol_index());

    println!("flop : {}", shuffled.draw(3).unwrap().by_symbol_index());
    println!("turn : {}", shuffled.draw(1).unwrap().by_symbol_index());
    println!("river: {}", shuffled.draw(1).unwrap().by_symbol_index());


The library has several demo programs in the examples directory.

For the traditional French Deck:

$> cargo run --example traditional
Long in English and German:
      Ace of Spades
      Ass von Spaten
      King of Spades
      König von Spaten
      Queen of Spades
      Dame von Spaten
   Short Symbols in en-US: A♠ K♠ Q♠ J♠ 1098765432♠ A♥ K♥ Q♥ J♥ 1098765432♥ A♦ K♦ Q♦ J♦ 1098765432♦ A♣ K♣ Q♣ J♣ 1098765432♣
   Short Symbols in de   : A♠ K♠ D♠ B♠ 1098765432♠ A♥ K♥ D♥ B♥ 1098765432♥ A♦ K♦ D♦ B♦ 1098765432♦ A♣ K♣ D♣ B♣ 1098765432♣
   Short Letters in en-US: AS KS QS JS 10S 9S 8S 7S 6S 5S 4S 3S 2S AH KH QH JH 10H 9H 8H 7H 6H 5H 4H 3H 2H AD KD QD JD 10D 9D 8D 7D 6D 5D 4D 3D 2D AC KC QC JC 10C 9C 8C 7C 6C 5C 4C 3C 2C
   Short Letters in de   : AS KS DS BS 10S 9S 8S 7S 6S 5S 4S 3S 2S AH KH DH BH 10H 9H 8H 7H 6H 5H 4H 3H 2H AD KD DD BD 10D 9D 8D 7D 6D 5D 4D 3D 2D AK KK DK BK 10K 9K 8K 7K 6K 5K 4K 3K 2K
   Shuffle Deck:           8C 2H QC 9D 4S 10D 8D 6D 5H JS 5D KS 6C 9H 6H JC KC 3H 7C 3C 8H 7H 4H 5C 5S 4C AC 4D AH QH QS JD 9S 2S 3S 2C 10S JH 9C KH 10H 7D 10C KD 8S 6S 7S QD AD 2D 3D AS
   Sort Deck:              AS KS QS JS 10S 9S 8S 7S 6S 5S 4S 3S 2S AH KH QH JH 10H 9H 8H 7H 6H 5H 4H 3H 2H AD KD QD JD 10D 9D 8D 7D 6D 5D 4D 3D 2D AC KC QC JC 10C 9C 8C 7C 6C 5C 4C 3C 2C

Also included are example programs for spades, pinochle, skat, canasta, euchre, handandfoot and tarot as well as example poker and bridge hands.


The goal of this library is to be able to support the creation of card decks of various sizes and suits. Out of the box, the library supports:

The project takes advantage of Project Fluent's Rust support to offer internationalization. Current languages supported are English and German.


  • Represent a specific type of card deck.
  • Validate that a collection of cards is valid for that type of deck.
  • Create a textual representation of a deck that can be serialized and deserialized.
  • Shuffle a deck
  • Verify that a specific card is playable given a set of discards.
  • Determine if two deck types are translatable.


Other Deck of Cards Libraries


Dev Dependencies

  • rstest - Fixture-based test framework for Rust



~210K SLoC