pub struct Move(pub Square, pub Square);Expand description
Represents a move that can occur on a board. A move is represented by the source square and the destination square.
Tuple Fields§
§0: Square§1: SquareImplementations§
Source§impl Move
impl Move
Sourcepub fn new(source: Square, destination: Square) -> Result<Self, NotationError>
pub fn new(source: Square, destination: Square) -> Result<Self, NotationError>
Creates a new Move instance from two given squares. Move instances have no context of a board or any checkers rules. Moves are simply a source and destination square. Move validation is expected to be done via other mechanisms.
Basic usage:
use checke_rs::position::{Move, Square};
let Move(source, dest) = Move::new(Square::Eight, Square::Nine).unwrap();
assert_eq!(source, Square::Eight);
assert_eq!(dest, Square::Nine);Sourcepub fn from_notation(text: &str) -> Result<Self, NotationError>
pub fn from_notation(text: &str) -> Result<Self, NotationError>
Create a new Move instance using the given checkers notation text.
use checke_rs::position::{Move, Square};
let Move(source, dest) = Move::from_notation("18x25").unwrap();
assert_eq!(source, Square::Eighteen);
assert_eq!(dest, Square::TwentyFive);Trait Implementations§
Source§impl TryFrom<&str> for Move
impl TryFrom<&str> for Move
Source§fn try_from(text: &str) -> Result<Self, Self::Error>
fn try_from(text: &str) -> Result<Self, Self::Error>
Converts a string slice representing checkers notation into a Move instance.
use checke_rs::position::{Move, Square};
let Move(source, dest) = Move::try_from("18x25").unwrap();
assert_eq!(source, Square::Eighteen);
assert_eq!(dest, Square::TwentyFive);Source§type Error = NotationError
type Error = NotationError
The type returned in the event of a conversion error.
impl Copy for Move
Auto Trait Implementations§
impl Freeze for Move
impl RefUnwindSafe for Move
impl Send for Move
impl Sync for Move
impl Unpin for Move
impl UnwindSafe for Move
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