pub struct Moves<'l> { /* private fields */ }Expand description
The list of all the legal moves on a position. It is returned by Position::legal_moves.
This type lies on the stack and has a fixed capacity of 218 moves, as there exists no reachable position with more legal moves1.
In 1964, Nenad Petrović published a composition with 218 legal moves. 60 years later, this was proven to be optimal by Tobs40. Even though the
Positiontype can represent some unreachable positions the proof still holds, as its definition of a position is even less restrictive. ↩
Implementations§
Source§impl<'l> Moves<'l>
impl<'l> Moves<'l>
Sourcepub fn en_passant_is_legal(&self) -> bool
pub fn en_passant_is_legal(&self) -> bool
Returns true if taking en passant is legal on the position.
Sourcepub fn get(&self, index: usize) -> Option<Move<'l>>
pub fn get(&self, index: usize) -> Option<Move<'l>>
Returns the move at the given index, if it exists.
Sourcepub fn sort_by<F>(&mut self, compare: F)
Available on crate feature alloc only.
pub fn sort_by<F>(&mut self, compare: F)
alloc only.Sorts the list in ascending order with a comparison function, preserving initial order of equal elements.
See slice::sort_by for details.
Sourcepub fn sort_unstable_by<F>(&mut self, compare: F)
pub fn sort_unstable_by<F>(&mut self, compare: F)
Sorts the list in ascending order with a comparison function, without preserving the initial order of equal elements.
See slice::sort_unstable_by for details.
Sourcepub fn select_nth_unstable(&mut self, index: usize) -> Move<'l>
pub fn select_nth_unstable(&mut self, index: usize) -> Move<'l>
Reorders the slice such that the element at index is at a sort-order position.
See slice::select_nth_unstable for details.
Sourcepub fn select_nth_unstable_by<F>(
&mut self,
index: usize,
compare: F,
) -> Move<'l>
pub fn select_nth_unstable_by<F>( &mut self, index: usize, compare: F, ) -> Move<'l>
Reorders the slice with a comparator function such that the element at index is at a
sort-order position.
See slice::select_nth_unstable_by for details.