Add 'From<InvalidError>' for 'FenError'

This commit is contained in:
Bruno BELANYI 2024-04-01 21:30:52 +01:00
parent a676094dc1
commit 829362dbce

View file

@ -27,6 +27,13 @@ impl std::fmt::Display for FenError {
impl std::error::Error for FenError {} impl std::error::Error for FenError {}
/// Allow converting a [InvalidError] into [FenError], for use with the '?' operator.
impl From<InvalidError> for FenError {
fn from(err: InvalidError) -> Self {
Self::InvalidPosition(err)
}
}
/// Convert the castling rights segment of a FEN string to an array of [CastleRights]. /// Convert the castling rights segment of a FEN string to an array of [CastleRights].
impl FromFen for [CastleRights; 2] { impl FromFen for [CastleRights; 2] {
type Err = FenError; type Err = FenError;