Skip to main content

Square

Enum Square 

Source
#[repr(u8)]
pub enum Square {
Show 64 variants A1 = 0, B1 = 1, C1 = 2, D1 = 3, E1 = 4, F1 = 5, G1 = 6, H1 = 7, A2 = 8, B2 = 9, C2 = 10, D2 = 11, E2 = 12, F2 = 13, G2 = 14, H2 = 15, A3 = 16, B3 = 17, C3 = 18, D3 = 19, E3 = 20, F3 = 21, G3 = 22, H3 = 23, A4 = 24, B4 = 25, C4 = 26, D4 = 27, E4 = 28, F4 = 29, G4 = 30, H4 = 31, A5 = 32, B5 = 33, C5 = 34, D5 = 35, E5 = 36, F5 = 37, G5 = 38, H5 = 39, A6 = 40, B6 = 41, C6 = 42, D6 = 43, E6 = 44, F6 = 45, G6 = 46, H6 = 47, A7 = 48, B7 = 49, C7 = 50, D7 = 51, E7 = 52, F7 = 53, G7 = 54, H7 = 55, A8 = 56, B8 = 57, C8 = 58, D8 = 59, E8 = 60, F8 = 61, G8 = 62, H8 = 63,
}
Expand description

The squares of a chess board.

Variants§

§

A1 = 0

§

B1 = 1

§

C1 = 2

§

D1 = 3

§

E1 = 4

§

F1 = 5

§

G1 = 6

§

H1 = 7

§

A2 = 8

§

B2 = 9

§

C2 = 10

§

D2 = 11

§

E2 = 12

§

F2 = 13

§

G2 = 14

§

H2 = 15

§

A3 = 16

§

B3 = 17

§

C3 = 18

§

D3 = 19

§

E3 = 20

§

F3 = 21

§

G3 = 22

§

H3 = 23

§

A4 = 24

§

B4 = 25

§

C4 = 26

§

D4 = 27

§

E4 = 28

§

F4 = 29

§

G4 = 30

§

H4 = 31

§

A5 = 32

§

B5 = 33

§

C5 = 34

§

D5 = 35

§

E5 = 36

§

F5 = 37

§

G5 = 38

§

H5 = 39

§

A6 = 40

§

B6 = 41

§

C6 = 42

§

D6 = 43

§

E6 = 44

§

F6 = 45

§

G6 = 46

§

H6 = 47

§

A7 = 48

§

B7 = 49

§

C7 = 50

§

D7 = 51

§

E7 = 52

§

F7 = 53

§

G7 = 54

§

H7 = 55

§

A8 = 56

§

B8 = 57

§

C8 = 58

§

D8 = 59

§

E8 = 60

§

F8 = 61

§

G8 = 62

§

H8 = 63

Implementations§

Source§

impl Square

Square Geometry API.

Source

pub const fn checked_add(self, direction: Direction) -> Option<Square>

Source

pub const fn full_ray(self, other: Square) -> Bitboard

Source

pub const fn index_after(self) -> Bitboard

Source

pub const fn index_before(self) -> Bitboard

Source

pub const fn east(self) -> Bitboard

Source

pub const fn west(self) -> Bitboard

Source

pub const fn between(self, other: Square) -> Bitboard

Source

pub const fn aligned(self, b: Square, c: Square) -> bool

Source§

impl Square

Square Move API.

Source

pub const fn attacks(self, piece: Piece, occupied: Bitboard) -> Bitboard

Source

pub const fn king_moves(self) -> Bitboard

Source

pub const fn knight_moves(self) -> Bitboard

Source

pub const fn pawn_attack_moves(self, player: Player) -> Bitboard

Source

pub const fn bishop_sight(self, occupied: Bitboard) -> Bitboard

Source

pub const fn rook_sight(self, occupied: Bitboard) -> Bitboard

Source

pub const fn queen_sight(self, occupied: Bitboard) -> Bitboard

Source§

impl Square

Square Finite Set API.

Source

pub const LEN: usize

Source

pub const ALL: [Self; 64]

Source

pub const fn name(self) -> &'static str

Source

pub const fn eq(self, other: Self) -> bool

Source

pub const fn index(self) -> usize

Source

pub const fn from_index(index: u8) -> Option<Self>

Source

pub fn iter() -> impl Iterator<Item = Self>

Source

pub fn iter_rev() -> impl Iterator<Item = Self>

Source§

impl Square

Source

pub const fn new(file: File, rank: Rank) -> Self

Source

pub fn rank_rev_iter() -> impl Iterator<Item = Square>

A8, B8, …, H8, A7, …, H1.

Source

pub const fn file(self) -> File

Source

pub const fn rank(self) -> Rank

Source

pub const fn coordinates(self) -> (File, Rank)

Trait Implementations§

Source§

impl Add<&[Direction]> for Square

Source§

type Output = Bitboard

The resulting type after applying the + operator.
Source§

fn add(self, directions: &[Direction]) -> Bitboard

Performs the + operation. Read more
Source§

impl Add<Direction> for Square

Source§

type Output = Option<Square>

The resulting type after applying the + operator.
Source§

fn add(self, direction: Direction) -> Option<Square>

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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Square

Source§

impl Debug for Square

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Square

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Square

Source§

impl Extend<Square> for Bitboard

Source§

fn extend<T: IntoIterator<Item = Square>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FiniteSet<{ $crate::finite_set!(@count $($variant),+) }> for Square

Source§

const ALL: [Self; 64]

Source§

const LEN: usize = N

Source§

fn iter() -> impl Iterator<Item = Self>

Source§

fn iter_rev() -> impl Iterator<Item = Self>

Source§

impl From<EnPassant> for Square

Source§

fn from(en_passant: EnPassant) -> Self

Converts to this type from the input type.
Source§

impl From<Square> for Bitboard

Source§

fn from(sq: Square) -> Bitboard

Converts to this type from the input type.
Source§

impl FromIterator<Square> for Bitboard

Source§

fn from_iter<T>(iter: T) -> Bitboard
where T: IntoIterator<Item = Square>,

Creates a value from an iterator. Read more
Source§

impl FromStr for Square

Source§

type Err = SquareError

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

fn from_str(square: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T> Index<Square> for Table<Square, T, { _ }>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, key: Square) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<Square> for Table<Square, T, { _ }>

Source§

fn index_mut(&mut self, key: Square) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Ord for Square

Source§

fn cmp(&self, other: &Square) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 Serialize for Square
where Self: Display,

Source§

fn serialize<__S>(&self, serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Square

Source§

impl TryFrom<Square> for EnPassant

Source§

type Error = ()

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

fn try_from(square: Square) -> Result<Self, ()>

Performs the conversion.

Auto Trait Implementations§

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.