/// Returns all moves that are legal in this game state, as well as the game states they result
/// in.
/// 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 all moves that are legal in this game state, as well as the game states they result
in.
Moves that don't change the game state are treated as illegal.
Returns all moves that are legal in this game state as well as the game states they result in . Moves that don ' t change the game state are treated as illegal .
pub fn legal_moves(&self) -> Vec<(GameState, Move)> {
        let mut legal_moves = Vec::new();
        // for all combinations of source and target position (where the two are different),
        // try to move cards from one to the other
        for &from_position in positions_except_for(&Position::Foundations) {
            for (from_card_collection, card) in self.pop_card_at_position(from_position) {
                for &to_position in positions_except_for(&from_position) {
                    if let Ok(to_card_collection) = self.add_card_at_position(to_position, card) {
                        legal_moves.push((
                            self.construct_next_game_state(from_card_collection.clone(), to_card_collection),
                            Move { card, from: from_position, to: to_position }
                        ));
                    }
                }
            }
        }
        legal_moves
    }
pub fn legal_moves ( & self ) -> Vec < ( GameState , Move ) > { let mut legal_moves = Vec :: new ( ) ; // for all combinations of source and target position (where the two are different), // try to move cards from one to the other for & from_position in positions_except_for ( & Position :: Foundations ) { for ( from_card_collection , card ) in self . pop_card_at_position ( from_position ) { for & to_position in positions_except_for ( & from_position ) { if let Ok ( to_card_collection ) = self . add_card_at_position ( to_position , card ) { legal_moves . push ( ( self . construct_next_game_state ( from_card_collection . clone ( ) , to_card_collection ) , Move { card , from : from_position , to : to_position } ) ) ; } } } } legal_moves }
Returns all moves that are legal in this game state, as well as the game states they result
in.
Returns all moves that are legal in this game state as well as the game states they result in .
&self
examples
```
TODO [v1] Add code examples (once FromStr is implemented for GameState)
```
` ` ` TODO [ v1 ] Add code examples ( once FromStr is implemented for GameState ) ` ` `