Struct shakmaty::square::Square [] [src]

pub struct Square(_);

A square index.

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

Errors when 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]

[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

[src]

This method tests for !=.

impl Ord for Square
[src]

[src]

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

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

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

[src]

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

[src]

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

[src]

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

[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.