diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-04-27 15:10:26 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-04-27 15:10:26 +0200 |
commit | 4205887223ab26e2950eea74ac1f9df4901695a9 (patch) | |
tree | 27e67841ed49d76dbd84ea7717fbcd86c0476d1b /src/gamedata.rs | |
parent | fbee69c9def92bf1c858fef283a01dd62f951f7e (diff) | |
download | evtclib-4205887223ab26e2950eea74ac1f9df4901695a9.tar.gz evtclib-4205887223ab26e2950eea74ac1f9df4901695a9.tar.bz2 evtclib-4205887223ab26e2950eea74ac1f9df4901695a9.zip |
derive Error for ParseBossError
The implementation was short, but since we're using thiserror anyway, we
might as well be consistent and derive the implementation.
Diffstat (limited to 'src/gamedata.rs')
-rw-r--r-- | src/gamedata.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/gamedata.rs b/src/gamedata.rs index 2e6927d..b7ffc11 100644 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -1,6 +1,7 @@ //! This module contains some low-level game data, such as different boss IDs. use num_derive::FromPrimitive; -use std::{fmt, str::FromStr}; +use thiserror::Error; +use std::str::FromStr; /// Enum containing all bosses with their IDs. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive)] @@ -62,15 +63,10 @@ pub enum Boss { } /// Error for when converting a string to the boss fails. -#[derive(Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Error)] +#[error("Invalid boss identifier: {0}")] pub struct ParseBossError(String); -impl fmt::Display for ParseBossError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Invalid boss identifier: {}", self.0) - } -} - impl FromStr for Boss { type Err = ParseBossError; |