aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gamedata.rs12
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;