mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/block/power.rs')
| -rw-r--r-- | src/block/power.rs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/block/power.rs b/src/block/power.rs index f5048c6..2c21cad 100644 --- a/src/block/power.rs +++ b/src/block/power.rs @@ -1,6 +1,5 @@ //! power connection and generation -use std::error::Error; -use std::fmt; +use thiserror::Error; use crate::block::simple::*; use crate::block::*; @@ -117,8 +116,9 @@ impl BlockLogic for ConnectorBlock { } } -#[derive(Debug)] +#[derive(Debug, Error)] pub enum ConnectorDeserializeError { + #[error("too many links ({have} but only {max} allowed)")] LinkCount { have: usize, max: u8 }, } @@ -131,18 +131,6 @@ impl ConnectorDeserializeError { } } -impl fmt::Display for ConnectorDeserializeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::LinkCount { have, max } => { - write!(f, "too many links ({have} but only {max} supported)") - } - } - } -} - -impl Error for ConnectorDeserializeError {} - #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct RGBA(u8, u8, u8, u8); |