1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{
error,
fmt::{Display, Formatter, Result},
};
use crate::Square;
#[derive(Clone, Copy, Debug)]
pub enum Error {
InvalidPlacing(Square),
InvalidMoving { from: Square, to: Square },
EmptyHand,
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result {
use self::Error::*;
match self {
InvalidPlacing(square) => write!(f, "Couldn't place on {}.", square),
InvalidMoving { from, to } => write!(f, "Couldn't move from {} to {}.", from, to),
EmptyHand => write!(f, "Couldn't extract a piece from empty hand."),
}
}
}
impl error::Error for Error {}