pub enum Rank {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
}Expand description
The rank component of a chess position.
Variants§
Implementations§
Source§impl Rank
impl Rank
Sourcepub fn up(self) -> Option<Self>
pub fn up(self) -> Option<Self>
Get the Rank above self, or None if no such rank exists.
§Example
assert_eq!(Rank::One.up(), Some(Rank::Two));
assert_eq!(Rank::Eight.up(), None);Sourcepub fn walk_up(self) -> impl Iterator<Item = Self>
pub fn walk_up(self) -> impl Iterator<Item = Self>
Returns an iterator over the ranks above, and including self.
§Example
let up: Vec<Rank> = Rank::Six.walk_up().collect();
assert_eq!(up, vec![Rank::Six, Rank::Seven, Rank::Eight]);Sourcepub fn down(self) -> Option<Self>
pub fn down(self) -> Option<Self>
Get the Rank below self, or None if no such rank exists.
§Example
assert_eq!(Rank::Seven.down(), Some(Rank::Six));
assert_eq!(Rank::One.down(), None);Sourcepub fn walk_down(self) -> impl Iterator<Item = Self>
pub fn walk_down(self) -> impl Iterator<Item = Self>
Returns an iterator over the ranks below, and including self.
§Example
let down: Vec<Rank> = Rank::Three.walk_down().collect();
assert_eq!(down, vec![Rank::Three, Rank::Two, Rank::One]);Sourcepub fn iter(self) -> impl DoubleEndedIterator<Item = Position>
pub fn iter(self) -> impl DoubleEndedIterator<Item = Position>
Create an iterator over all positions in the Rank, in ascending order.
§Example
let ranks: Vec<Position> = Rank::Four.iter().collect();
assert_eq!(ranks, vec![A4, B4, C4, D4, E4, F4, G4, H4]);Trait Implementations§
Source§impl Ord for Rank
impl Ord for Rank
Source§impl PartialOrd for Rank
impl PartialOrd for Rank
impl Copy for Rank
impl Eq for Rank
impl StructuralPartialEq for Rank
Auto Trait Implementations§
impl Freeze for Rank
impl RefUnwindSafe for Rank
impl Send for Rank
impl Sync for Rank
impl Unpin for Rank
impl UnwindSafe for Rank
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