pub struct Card64(/* private fields */);Expand description
Card Set
§Memory Layout:
[63, 48]: xxxAKQJT 98765432 // Club
[47, 32]: xxxAKQJT 98765432 // Diamond
[31, 16]: xxxAKQJT 98765432 // Heart
[15, 0]: xxxAKQJT 98765432 // Spade, x: unusedImplementations§
Source§impl Card64
impl Card64
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Checks whether all rank masks are unset
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let c64: Card64 = Card64::from(Card::new(R2, S));
assert!(!c64.is_empty());Sourcepub fn contains(self, other: Self) -> bool
pub fn contains(self, other: Self) -> bool
checks whether another Card64 is a subset
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let c64_2s: Card64 = Card64::from(Card::new(R2, S));
let c64_2h: Card64 = Card64::from(Card::new(R2, H));
let c64_2s_2h: Card64 = c64_2s | c64_2h;
assert!(c64_2s_2h.contains(c64_2h));
assert!(!c64_2s.contains(c64_2h));Sourcepub const fn contains_card(self, c: Card) -> bool
pub const fn contains_card(self, c: Card) -> bool
Sourcepub const fn count(&self) -> PQLCardCount
pub const fn count(&self) -> PQLCardCount
Returns the number of marked cards
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let c64: Card64 = Card64::from(Card::new(R2, S));
assert_eq!(c64.count(), 1);Sourcepub const fn count_by_rank(self, r: Rank) -> PQLCardCount
pub const fn count_by_rank(self, r: Rank) -> PQLCardCount
Returns the number of marked cards of rank r
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let c64: Card64 = Card64::all();
assert_eq!(c64.count_by_rank(RA), 4);Sourcepub const fn count_by_suit(self, s: Suit) -> PQLCardCount
pub const fn count_by_suit(self, s: Suit) -> PQLCardCount
Returns the number of marked cards of suit s
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let c64: Card64 = Card64::all();
assert_eq!(c64.count_by_suit(D), 13);Sourcepub fn set_available_card_by_rank(&mut self, r: Rank)
pub fn set_available_card_by_rank(&mut self, r: Rank)
Attempts to mark a card of rank r in the order S, H, D, C
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let mut c64: Card64 = Card64::from(Card::new(R2, S));
c64.set_available_card_by_rank(R2);
assert!(c64.contains_card(Card::new(R2, H)));Sourcepub const fn normalize(&mut self)
pub const fn normalize(&mut self)
Normalize u64 so that each u16 indicates rank count
§Examples
use open_pql::{Card, Card64, Rank::*, Suit::*};
let mut c64: Card64 =
Card64::from([Card::new(R2, D), Card::new(R2, C)].as_ref());
c64.normalize();
assert_eq!(
Card64::from([Card::new(R2, S), Card::new(R2, H)].as_ref()),
c64
);pub const fn ranks_by_suit(self, s: Suit) -> Rank16
pub const fn from_ranks(rs: Rank16) -> Self
pub const fn ranks(self) -> Rank16
pub const fn iter(self) -> CardIter ⓘ
pub const fn iter_ranks(self) -> RanksIter ⓘ
Trait Implementations§
Source§impl BitAndAssign for Card64
impl BitAndAssign for Card64
Source§fn bitand_assign(&mut self, rhs: Card64)
fn bitand_assign(&mut self, rhs: Card64)
Performs the
&= operation. Read moreSource§impl BitOrAssign for Card64
impl BitOrAssign for Card64
Source§fn bitor_assign(&mut self, rhs: Card64)
fn bitor_assign(&mut self, rhs: Card64)
Performs the
|= operation. Read moreimpl Copy for Card64
impl Eq for Card64
impl StructuralPartialEq for Card64
Auto Trait Implementations§
impl Freeze for Card64
impl RefUnwindSafe for Card64
impl Send for Card64
impl Sync for Card64
impl Unpin for Card64
impl UnwindSafe for Card64
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