Square

Enum Square 

Source
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

Source

pub const N: usize = 49usize

N represents the total number of Squares in an Ataxx Board.

Source

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);
Source

pub fn file(self) -> File

file returns the File of the current Square.

use ataxx::*;

assert_eq!(Square::A1.file(), File::A);
Source

pub fn rank(self) -> Rank

rank returns the Rank of the current Square.

use ataxx::*;

assert_eq!(Square::A1.rank(), Rank::First);
Source

pub fn north(self) -> Self

north returns the Square to the North of this one.

use ataxx::*;

assert_eq!(Square::D4.north(), Square::D5);
Source

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

pub fn east(self) -> Self

east returns the Square to the East of this one.

use ataxx::*;

assert_eq!(Square::D4.east(), Square::E4);
Source

pub fn west(self) -> Self

west returns the Square to the West of this one.

use ataxx::*;

assert_eq!(Square::D4.west(), Square::C4);
Source§

impl Square

Source

pub fn unsafe_from<T: ToPrimitive>(number: T) -> Self

Trait Implementations§

Source§

impl BitOr<Square> for BitBoard

Source§

type Output = BitBoard

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Square) -> Self::Output

Performs the | operation. Read more
Source§

impl Clone for Square

Source§

fn clone(&self) -> Square

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Square

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Debug implements Debug formatting for a Square. It uses Square::Display behind the hood.

Source§

impl Display for Square

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display formats the given Square in the format <file><rank>. For how <file> and <rank> are formatted, see the documentation for File::Display and Rank::Display trait implementations.

use ataxx::*;

assert_eq!(Square::A1.to_string(), "a1");
Source§

impl From<Square> for BitBoard

Source§

fn from(square: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for i16

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for i32

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for i64

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for i8

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for isize

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for u16

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for u32

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for u64

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for u8

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for usize

Source§

fn from(number: Square) -> Self

Converts to this type from the input type.
Source§

impl FromPrimitive for Square

Source§

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>

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>

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>

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>

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>

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>

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 more
Source§

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>

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>

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>

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>

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 more
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl FromStr for Square

Source§

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

The associated error which can be returned from parsing.
Source§

impl IntoEnumIterator for Square

Source§

impl PartialEq for Square

Source§

fn eq(&self, other: &Square) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Square

Source§

fn partial_cmp(&self, other: &Square) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Square> for BitBoard

Source§

type Output = BitBoard

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Square) -> Self::Output

Performs the - operation. Read more
Source§

impl TryFrom<i16> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: i16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<i32> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: i32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<i64> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: i64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<i8> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: i8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<isize> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: isize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u16> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: u16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u8> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<usize> for Square

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(number: usize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Square

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.