pub enum Square {
Show 49 variants
A1,
B1,
C1,
D1,
E1,
F1,
G1,
A2,
B2,
C2,
D2,
E2,
F2,
G2,
A3,
B3,
C3,
D3,
E3,
F3,
G3,
A4,
B4,
C4,
D4,
E4,
F4,
G4,
A5,
B5,
C5,
D5,
E5,
F5,
G5,
A6,
B6,
C6,
D6,
E6,
F6,
G6,
A7,
B7,
C7,
D7,
E7,
F7,
G7,
}Expand description
Square represents all the squares present on an Ataxx Board.
The index of each Square is equal to rank-index * 8 + file-index.
Variants§
A1
B1
C1
D1
E1
F1
G1
A2
B2
C2
D2
E2
F2
G2
A3
B3
C3
D3
E3
F3
G3
A4
B4
C4
D4
E4
F4
G4
A5
B5
C5
D5
E5
F5
G5
A6
B6
C6
D6
E6
F6
G6
A7
B7
C7
D7
E7
F7
G7
Implementations§
Source§impl Square
impl Square
Sourcepub fn new(file: File, rank: Rank) -> Square
pub fn new(file: File, rank: Rank) -> Square
new creates a new Square from the given File and Rank.
use ataxx::*;
assert_eq!(Square::new(File::A, Rank::First), Square::A1);Sourcepub fn file(self) -> File
pub fn file(self) -> File
file returns the File of the current Square.
use ataxx::*;
assert_eq!(Square::A1.file(), File::A);Sourcepub fn rank(self) -> Rank
pub fn rank(self) -> Rank
rank returns the Rank of the current Square.
use ataxx::*;
assert_eq!(Square::A1.rank(), Rank::First);Sourcepub fn north(self) -> Self
pub fn north(self) -> Self
north returns the Square to the North of this one.
use ataxx::*;
assert_eq!(Square::D4.north(), Square::D5);Sourcepub fn south(self) -> Self
pub fn south(self) -> Self
south returns the Square to the South of this one.
use ataxx::*;
assert_eq!(Square::D4.south(), Square::D3);Source§impl Square
impl Square
pub fn unsafe_from<T: ToPrimitive>(number: T) -> Self
Trait Implementations§
Source§impl FromPrimitive for Square
impl FromPrimitive for Square
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
Converts an
u16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
Converts an
u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§impl FromStr for Square
impl FromStr for Square
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
from_str converts a square given in the format <file><rank> into
a Square. For the formats of <file> and <rank> see the documentation
for File::FromStr and Rank::FromStr.
It is effectively the inverse operation of Display.
use ataxx::*;
use std::str::FromStr;
assert_eq!(Square::from_str("a1").unwrap(), Square::A1);Source§type Err = SquareParseError
type Err = SquareParseError
The associated error which can be returned from parsing.
Source§impl IntoEnumIterator for Square
impl IntoEnumIterator for Square
type Iterator = SquareIter
fn iter() -> SquareIter ⓘ
Source§impl PartialOrd for Square
impl PartialOrd for Square
impl Copy for Square
impl StructuralPartialEq for Square
Auto Trait Implementations§
impl Freeze for Square
impl RefUnwindSafe for Square
impl Send for Square
impl Sync for Square
impl Unpin for Square
impl UnwindSafe for Square
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