#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Error {
EmptyShape,
TooManyDimensions,
DimensionTooSmall,
DimensionTooLarge,
TooManySquares,
IndexOutOfRange,
HandUnderflow,
TooManyPieces,
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let message = match self {
Self::EmptyShape => "shape must have at least one dimension",
Self::TooManyDimensions => "shape exceeds the maximum number of dimensions",
Self::DimensionTooSmall => "a dimension size must be at least 1",
Self::DimensionTooLarge => "a dimension size exceeds the maximum",
Self::TooManySquares => "the board exceeds the maximum number of squares",
Self::IndexOutOfRange => "a board index is out of range",
Self::HandUnderflow => "cannot remove a piece that is not in the hand",
Self::TooManyPieces => "the number of pieces exceeds the number of squares",
};
f.write_str(message)
}
}
impl core::error::Error for Error {}