Enum shakmaty::Square [] [src]

#[repr(i8)]
pub enum Square { A1, B1, C1, D1, E1, F1, G1, H1, A2, B2, C2, D2, E2, F2, G2, H2, A3, B3, C3, D3, E3, F3, G3, H3, A4, B4, C4, D4, E4, F4, G4, H4, A5, B5, C5, D5, E5, F5, G5, H5, A6, B6, C6, D6, E6, F6, G6, H6, A7, B7, C7, D7, E7, F7, G7, H7, A8, B8, C8, D8, E8, F8, G8, H8, }

A square index.

Variants

Methods

impl Square
[src]

[src]

Create a Square from in integer index.

Panics

Panics if the index is not in the range 0..=63.

[src]

Tries to create a Square from an integer index in the range 0..=63.

[src]

Creates a Square from an integer index.

Unsafety

It is the callers responsibility to ensure it is in the range 0..=63.

[src]

Tries to create a square from zero-based file and rank indexes.

[src]

Creates a Square from zero-based file and rank indexes.

Unsafety

It is the callers responsibility to ensure that file and rank are in the range 0..=7.

[src]

Parses a square name.

Errors

Returns InvalidSquareName if the input is not a valid square name in lowercase ASCII characters.

Example

use shakmaty::Square;

let sq = Square::from_bytes(b"a5")?;
assert_eq!(sq, Square::A5);

[src]

[src]

[src]

[src]

[src]

[src]

Flip the square horizontally.

use shakmaty::Square;

assert_eq!(Square::H1.flip_horizontal(), Square::A1);
assert_eq!(Square::D3.flip_horizontal(), Square::E3);

[src]

Flip the square vertically.

use shakmaty::Square;

assert_eq!(Square::A8.flip_vertical(), Square::A1);
assert_eq!(Square::D3.flip_vertical(), Square::D6);

[src]

Flip at the a1-h8 diagonal by swapping file and rank.

use shakmaty::Square;

assert_eq!(Square::A1.flip_diagonal(), Square::A1);
assert_eq!(Square::A3.flip_diagonal(), Square::C1);

[src]

Tests is the square is a light square.

use shakmaty::Square;

assert!(Square::D1.is_light());
assert!(!Square::D8.is_light());

[src]

Tests is the square is a dark square.

use shakmaty::Square;

assert!(Square::E1.is_dark());
assert!(!Square::E8.is_dark());

[src]

The distance between the two squares, i.e. the number of king steps to get from one square to the other.

use shakmaty::Square;

assert_eq!(Square::A2.distance(Square::B5), 3);

[src]

Combines two squares, taking the file from the first and the rank from the second.

use shakmaty::Square;

assert_eq!(Square::D3.combine(Square::F5), Square::D5);

Trait Implementations

impl Copy for Square
[src]

impl Clone for Square
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Square
[src]

impl PartialEq for Square
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Ord for Square
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl PartialOrd for Square
[src]

[src]

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

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Hash for Square
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Sub for Square
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl FromStr for Square
[src]

The associated error which can be returned from parsing.

[src]

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

impl Display for Square
[src]

[src]

Formats the value using the given formatter. Read more

impl Debug for Square
[src]

[src]

Formats the value using the given formatter.