pub struct Board { /* private fields */ }Expand description
A snapshot of a board
Construct via Board::try_new, which handles both start-of-trick
(use CurrentTrick::new) and mid-trick (0–3 played cards) cases. The
invariants below are enforced by the constructor.
§Invariants
remainingis a validPartialDeal(≤13 cards per hand, pairwise disjoint).- Each card in the current trick is absent from every remaining hand (the “already played” invariant).
- Uniform-size-after-restoration: putting the
k = current_trick.len()table cards back into their players’ hands yields a subset where all four hands share a common sizem. Equivalently, thekseats starting atcurrent_trick.leader()(in playing order:leader,leader.lho(), …) have sizem − 1and the remaining4 − kseats have sizem.
Implementations§
Source§impl Board
impl Board
Sourcepub fn try_new(
remaining: PartialDeal,
current_trick: CurrentTrick,
) -> Result<Self, BoardError>
pub fn try_new( remaining: PartialDeal, current_trick: CurrentTrick, ) -> Result<Self, BoardError>
Construct a mid-trick board from a pre-validated CurrentTrick and
the cards remaining in each hand.
§Errors
Returns a BoardError if the invariants documented on Board do
not hold.
Sourcepub fn current_cards(&self) -> &[Card]
pub fn current_cards(&self) -> &[Card]
Cards already played to the current trick, in playing order
Sourcepub const fn current_trick(&self) -> &CurrentTrick
pub const fn current_trick(&self) -> &CurrentTrick
The current trick — cards played so far plus trump and leader
Sourcepub const fn remaining(&self) -> &PartialDeal
pub const fn remaining(&self) -> &PartialDeal
Remaining cards in each hand
Trait Implementations§
impl Eq for Board
impl StructuralPartialEq for Board
Auto Trait Implementations§
impl Freeze for Board
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnsafeUnpin for Board
impl UnwindSafe for Board
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