Struct Suit4

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

Suit Masks

A compact bit-set representation for storing multiple suits using a single u8. Each bit represents whether a specific suit is present in the set. Supports efficient set operations like union, intersection, and membership testing.

§Memory Layout:

[8, 0]:   xxxxCDHS // x: unused

§Examples

use open_pql::{Suit::*, Suit4};

let mut suits = Suit4::default();
suits.set(S);
suits.set(H);

assert!(suits.contains_suit(S));
assert_eq!(suits.count(), 2);

Implementations§

Source§

impl Suit4

Source

pub const fn is_empty(self) -> bool

Checks whether all suit masks are unset

§Examples
use open_pql::{Suit, Suit4};

let empty: Suit4 = Suit4::default();
let not_empty: Suit4 = Suit4::from(Suit::D);

assert!(empty.is_empty());
assert!(!not_empty.is_empty());
Source

pub const fn set(&mut self, s: Suit)

Mark a Suit

§Examples
use open_pql::{Suit, Suit4};

let mut suits: Suit4 = Suit4::default();
suits.set(Suit::D);

assert_eq!(suits, Suit4::from(Suit::D));
Source

pub const fn unset(&mut self, s: Suit)

Unmark a Suit

§Examples
use open_pql::{Suit, Suit4};

let mut suits: Suit4 = Suit4::from(Suit::D);
suits.unset(Suit::D);

assert_eq!(suits, Suit4::default());
Source

pub const fn contains_suit(self, s: Suit) -> bool

Checks whether a Suit is marked

§Examples
use open_pql::{Suit, Suit4};

let mut suits: Suit4 = Suit4::from(Suit::D);

assert!(suits.contains_suit(Suit::D));
assert!(!suits.contains_suit(Suit::H));
Source

pub const fn count(&self) -> PQLCardCount

Returns the number of marked suits

§Examples
use open_pql::{Suit, Suit4};

let mut suits: Suit4 = Suit4::from(Suit::D);

assert_eq!(suits.count(), 1);

Trait Implementations§

Source§

impl BitAnd for Suit4

Source§

type Output = Suit4

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitOr for Suit4

Source§

type Output = Suit4

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl Clone for Suit4

Source§

fn clone(&self) -> Suit4

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 Suit4

Source§

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

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

impl Default for Suit4

Source§

fn default() -> Suit4

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

impl From<&[Suit]> for Suit4

Source§

fn from(ss: &[Suit]) -> Self

Converts to this type from the input type.
Source§

impl From<Card64> for Suit4

Source§

fn from(c: Card64) -> Self

Converts to this type from the input type.
Source§

impl From<Suit> for Suit4

Source§

fn from(s: Suit) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Suit4

Source§

fn eq(&self, other: &Suit4) -> 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 Copy for Suit4

Source§

impl Eq for Suit4

Source§

impl StructuralPartialEq for Suit4

Auto Trait Implementations§

§

impl Freeze for Suit4

§

impl RefUnwindSafe for Suit4

§

impl Send for Suit4

§

impl Sync for Suit4

§

impl Unpin for Suit4

§

impl UnwindSafe for Suit4

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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, 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.