bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct StrainFlags : u8 {
const CLUBS = 0x01;
const DIAMONDS = 0x02;
const HEARTS = 0x04;
const SPADES = 0x08;
const NOTRUMP = 0x10;
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NonEmptyStrainFlags(StrainFlags);
impl NonEmptyStrainFlags {
pub const ALL: Self = Self(StrainFlags::all());
#[must_use]
pub const fn new(flags: StrainFlags) -> Option<Self> {
if flags.is_empty() {
None
} else {
Some(Self(flags))
}
}
#[must_use]
pub const fn get(self) -> StrainFlags {
self.0
}
}
impl From<NonEmptyStrainFlags> for StrainFlags {
#[inline]
fn from(flags: NonEmptyStrainFlags) -> Self {
flags.0
}
}