Add 'TryInto<Square>' for 'Bitboard'
This commit is contained in:
parent
bc67ee3e9a
commit
6976c60fe6
2 changed files with 55 additions and 0 deletions
19
src/board/bitboard/error.rs
Normal file
19
src/board/bitboard/error.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum IntoSquareError {
|
||||
/// The board is empty.
|
||||
EmptyBoard,
|
||||
/// The board contains more than one square.
|
||||
TooManySquares,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for IntoSquareError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let error_msg = match self {
|
||||
Self::EmptyBoard => "The board is empty",
|
||||
Self::TooManySquares => "The board contains more than one square",
|
||||
};
|
||||
write!(f, "{}", error_msg)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for IntoSquareError {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue