pub struct HandN<const N: usize>(/* private fields */);Expand description
A hand of N cards
Represents a fixed-size collection of N cards that are automatically sorted upon creation. Cards are maintained in sorted order for consistent comparison and hashing. This type is used for poker hands, flops, and other fixed-size card collections.
§Examples
use open_pql::{Card, HandN, Rank::*, Suit::*};
let cards = [Card::new(RA, S), Card::new(RK, H), Card::new(RQ, D)];
let hand: HandN<3> = HandN::from_slice(&cards);
assert_eq!(hand.len(), 3);
assert!(!hand.is_empty());
assert_eq!(hand[0], Card::new(RQ, D)); // Cards are sortedImplementations§
Source§impl<const N: usize> HandN<N>
impl<const N: usize> HandN<N>
Sourcepub fn from_slice(cs: &[Card]) -> Self
pub fn from_slice(cs: &[Card]) -> Self
Creates a hand from a slice of cards
pub fn to_vec(&self) -> Vec<Card>
Sourcepub fn iter(&self) -> impl Iterator<Item = Card> + '_
pub fn iter(&self) -> impl Iterator<Item = Card> + '_
Returns an iterator over the cards in the hand
pub fn iter_all_short() -> HandIter<true, N> ⓘ
pub fn iter_all() -> HandIter<false, N> ⓘ
Source§impl<const N: usize> HandN<N>
impl<const N: usize> HandN<N>
pub fn new_iso_with_mapping(cards: &[Card], mapping: &mut SuitMapping) -> Self
pub fn new_iso(cards: &[Card]) -> (Self, SuitMapping)
Trait Implementations§
Source§impl<'a, const N: usize> IntoIterator for &'a HandN<N>
impl<'a, const N: usize> IntoIterator for &'a HandN<N>
Source§impl<const N: usize> Ord for HandN<N>
impl<const N: usize> Ord for HandN<N>
Source§impl<const N: usize> PartialOrd for HandN<N>
impl<const N: usize> PartialOrd for HandN<N>
impl<const N: usize> Copy for HandN<N>
impl<const N: usize> Eq for HandN<N>
impl<const N: usize> StructuralPartialEq for HandN<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for HandN<N>
impl<const N: usize> RefUnwindSafe for HandN<N>
impl<const N: usize> Send for HandN<N>
impl<const N: usize> Sync for HandN<N>
impl<const N: usize> Unpin for HandN<N>
impl<const N: usize> UnwindSafe for HandN<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more