pub fn allows_move(&self, game_move: Move) -> bool {
        // moves that don't change the game state are treated as illegal
        if game_move.from == game_move.to {
            return false;
        }

        // check whether the card can be removed from position game_move.from
        let can_pop_card = match game_move.from {
            Position::Cascade(i) => can_pop_from_collection(game_move.card, &self.cascades[i]),
            Position::Foundations => false,
            Position::Freecell(i) => can_pop_from_collection(game_move.card, &self.freecells[i]),
        };
        if !can_pop_card { return false; }

        // check whether the card can be added to position game_move.to
        let can_add_card = match game_move.to {
            Position::Cascade(i) => self.cascades[i].add_card(game_move.card).is_ok(),
            Position::Foundations => self.foundations.add_card(game_move.card).is_ok(),
            Position::Freecell(i) => self.freecells[i].add_card(game_move.card).is_ok(),
        };
        can_add_card
    }
/// Returns `true` if the given move is legal in this game state, `false` otherwise.
/// Moves that don't change the game state are treated as illegal.
///
/// # Examples
///
/// ```
/// // TODO [v1] Add code examples (once FromStr is implemented for GameState)
/// ```
Returns `true` if the given move is legal in this game state, `false` otherwise.
Moves that don't change the game state are treated as illegal.
Returns ` true ` if the given move is legal in this game state ` false ` otherwise . Moves that don ' t change the game state are treated as illegal .
pub fn allows_move(&self, game_move: Move) -> bool {
        // moves that don't change the game state are treated as illegal
        if game_move.from == game_move.to {
            return false;
        }
        // check whether the card can be removed from position game_move.from
        let can_pop_card = match game_move.from {
            Position::Cascade(i) => can_pop_from_collection(game_move.card, &self.cascades[i]),
            Position::Foundations => false,
            Position::Freecell(i) => can_pop_from_collection(game_move.card, &self.freecells[i]),
        };
        if !can_pop_card { return false; }
        // check whether the card can be added to position game_move.to
        let can_add_card = match game_move.to {
            Position::Cascade(i) => self.cascades[i].add_card(game_move.card).is_ok(),
            Position::Foundations => self.foundations.add_card(game_move.card).is_ok(),
            Position::Freecell(i) => self.freecells[i].add_card(game_move.card).is_ok(),
        };
        can_add_card
    }
pub fn allows_move ( & self , game_move : Move ) -> bool { // moves that don't change the game state are treated as illegal if game_move . from == game_move . to { return false ; } // check whether the card can be removed from position game_move.from let can_pop_card = match game_move . from { Position :: Cascade ( i ) => can_pop_from_collection ( game_move . card , & self . cascades [ i ] ) , Position :: Foundations => false , Position :: Freecell ( i ) => can_pop_from_collection ( game_move . card , & self . freecells [ i ] ) , } ; if ! can_pop_card { return false ; } // check whether the card can be added to position game_move.to let can_add_card = match game_move . to { Position :: Cascade ( i ) => self . cascades [ i ] . add_card ( game_move . card ) . is_ok ( ) , Position :: Foundations => self . foundations . add_card ( game_move . card ) . is_ok ( ) , Position :: Freecell ( i ) => self . freecells [ i ] . add_card ( game_move . card ) . is_ok ( ) , } ; can_add_card }
Returns `true` if the given move is legal in this game state, `false` otherwise.
Returns ` true ` if the given move is legal in this game state ` false ` otherwise .
&self
game_move
Move
&self
game_move
Move
examples
```
TODO [v1] Add code examples (once FromStr is implemented for GameState)
```
` ` ` TODO [ v1 ] Add code examples ( once FromStr is implemented for GameState ) ` ` `