pub struct Field { /* private fields */ }
Expand description
Represents a board location in a chess game.
Implementations§
Source§impl Field
impl Field
Sourcepub const fn new(column: u8, row: u8) -> Option<Self>
pub const fn new(column: u8, row: u8) -> Option<Self>
Creates a field from a column and a row. Both values must be between 0-7 or None will be returned. For easy usage use the board constants as arguments (Board::)
Sourcepub fn new_from_usize(column: usize, row: usize) -> Option<Self>
pub fn new_from_usize(column: usize, row: usize) -> Option<Self>
Converts two usize params into a field.
column
- The column of the new fieldrow
- The row of the new fieldreturns
- A field containing the column and row parameters
Sourcepub fn new_from_string(field: &str) -> Option<Self>
pub fn new_from_string(field: &str) -> Option<Self>
Converts a field from a string into the field data type if possible. The string has to follow the format: column + row. Example: a3.
field
- The string which should be converted into aField
objectreturns
- AField
object
Sourcepub fn set_column(&mut self, column: u8)
pub fn set_column(&mut self, column: u8)
Sets the column of the field. The given value must be between 0-7 (inclusive). Otherwise the value will be ignored.
Sourcepub fn set_row(&mut self, row: u8)
pub fn set_row(&mut self, row: u8)
Sets the row of the field. The given value must be between 0-7 (inclusive). Otherwise the value will be ignored.
Sourcepub fn get_column(&self) -> u8
pub fn get_column(&self) -> u8
Returns the column of the field.
Trait Implementations§
impl Copy for Field
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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