Skip to main content

Holding

Struct Holding 

Source
pub struct Holding(/* private fields */);
Expand description

A set of cards of the same suit

Implementations§

Source§

impl Holding

Source

pub const EMPTY: Self

The empty set

Source

pub const ALL: Self

The set containing all possible ranks (2..=14)

Source

pub const fn len(self) -> usize

The number of cards in the holding

Source

pub const fn is_empty(self) -> bool

Whether the holding is empty

Source

pub const fn contains(self, rank: Rank) -> bool

Whether the holding contains a rank

Source

pub const fn insert(&mut self, rank: Rank) -> bool

Insert a rank into the holding, returning whether it was newly inserted

Source

pub const fn remove(&mut self, rank: Rank) -> bool

Remove a rank from the holding, returning whether it was present

Source

pub const fn toggle(&mut self, rank: Rank) -> bool

Toggle a rank in the holding, returning whether it is now present

Source

pub const fn set(&mut self, rank: Rank, condition: bool)

Conditionally insert/remove a rank from the holding

Source

pub const fn iter(self) -> HoldingIter

Iterate over the ranks in the holding

Source

pub const fn to_bits(self) -> u16

As a bitset of ranks

Source

pub const fn from_bits_retain(bits: u16) -> Self

Create a holding from a bitset of ranks, retaining invalid ranks

Source

pub const fn contains_unknown_bits(self) -> bool

Whether the holding contains an invalid rank

Source

pub const fn from_bits(bits: u16) -> Option<Self>

Create a holding from a bitset of ranks, checking for invalid ranks

Source

pub const fn from_bits_truncate(bits: u16) -> Self

Create a holding from a bitset of ranks, removing invalid ranks

Source

pub const fn from_rank(rank: Rank) -> Self

Create a holding from a rank

Trait Implementations§

Source§

impl BitAnd for Holding

Source§

type Output = Holding

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
Source§

impl BitAndAssign for Holding

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for Holding

Source§

type Output = Holding

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for Holding

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for Holding

Source§

type Output = Holding

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Holding

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for Holding

Source§

fn clone(&self) -> Holding

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Holding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Holding

Source§

fn default() -> Holding

Returns the “default value” for a type. Read more
Source§

impl Display for Holding

Show cards in descending order

  1. The ten is shown as T for PBN compatibility.
  2. This implementation ignores formatting flags for simplicity and speed. If you want to pad or align the output, use fmt::Formatter::pad.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Holding

Source§

type Err = ParseHoldingError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Holding

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for Holding

Source§

type Item = Rank

The type of the elements being iterated over.
Source§

type IntoIter = HoldingIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> HoldingIter

Creates an iterator from a value. Read more
Source§

impl Not for Holding

Source§

type Output = Holding

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self

Performs the unary ! operation. Read more
Source§

impl PartialEq for Holding

Source§

fn eq(&self, other: &Holding) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for Holding

Source§

type Output = Holding

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for Holding

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for Holding

Source§

impl Eq for Holding

Source§

impl StructuralPartialEq for Holding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.