Struct shogi::hand::Hand
[−]
[src]
pub struct Hand { /* fields omitted */ }
Manages the number of each pieces in each player's hand.
Examples
use shogi::{Color, Hand, Piece, PieceType}; let mut hand: Hand = Default::default(); let black_pawn = Piece{piece_type: PieceType::Pawn, color: Color::Black}; let white_pawn = Piece{piece_type: PieceType::Pawn, color: Color::White}; hand.set(&black_pawn, 2); hand.increment(&black_pawn); assert_eq!(3, hand.get(&black_pawn)); assert_eq!(0, hand.get(&white_pawn));
Methods
impl Hand
[src]
fn get(&self, p: &Piece) -> u8
Returns a number of the given piece.
fn set(&mut self, p: &Piece, num: u8)
Sets a number of the given piece.
fn increment(&mut self, p: &Piece)
Increments a number of the given piece.
fn decrement(&mut self, p: &Piece)
Decrements a number of the given piece.
fn clear(&mut self)
Clears all pieces.