diff --git a/all-is-cubes-ui/src/vui/widget_trait.rs b/all-is-cubes-ui/src/vui/widget_trait.rs index 9087ec1bc..67c0b36ba 100644 --- a/all-is-cubes-ui/src/vui/widget_trait.rs +++ b/all-is-cubes-ui/src/vui/widget_trait.rs @@ -2,8 +2,8 @@ use all_is_cubes::time::Tick; use alloc::sync::Arc; -use core::fmt::Debug; use core::error::Error; +use core::fmt::Debug; use std::sync::Mutex; use all_is_cubes::behavior::{self, Behavior}; diff --git a/all-is-cubes-ui/src/vui/widgets/progress_bar.rs b/all-is-cubes-ui/src/vui/widgets/progress_bar.rs index 60481ec5a..9dc057610 100644 --- a/all-is-cubes-ui/src/vui/widgets/progress_bar.rs +++ b/all-is-cubes-ui/src/vui/widgets/progress_bar.rs @@ -178,7 +178,8 @@ impl vui::WidgetController for ProgressBarController { fn step( &mut self, _context: &vui::WidgetContext<'_>, - ) -> Result<(vui::WidgetTransaction, vui::Then), Box> { + ) -> Result<(vui::WidgetTransaction, vui::Then), Box> + { if !self.todo.get_and_clear() { return Ok((SpaceTransaction::default(), vui::Then::Step)); } diff --git a/all-is-cubes/src/behavior.rs b/all-is-cubes/src/behavior.rs index 1dad49ab9..804fa5229 100644 --- a/all-is-cubes/src/behavior.rs +++ b/all-is-cubes/src/behavior.rs @@ -790,8 +790,8 @@ pub struct BehaviorTransactionConflict { key: Key, } - impl core::error::Error for BehaviorTransactionMismatch {} - impl core::error::Error for BehaviorTransactionConflict {} +impl core::error::Error for BehaviorTransactionMismatch {} +impl core::error::Error for BehaviorTransactionConflict {} impl fmt::Display for BehaviorTransactionMismatch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/all-is-cubes/src/block/eval/control.rs b/all-is-cubes/src/block/eval/control.rs index 3e5a1c147..d82fd63ca 100644 --- a/all-is-cubes/src/block/eval/control.rs +++ b/all-is-cubes/src/block/eval/control.rs @@ -285,15 +285,15 @@ impl fmt::Display for EvalBlockError { } } - impl core::error::Error for EvalBlockError { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match &self.kind { - ErrorKind::BudgetExceeded { .. } => None, - ErrorKind::PriorBudgetExceeded { .. } => None, - ErrorKind::Handle(e) => Some(e), - } +impl core::error::Error for EvalBlockError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match &self.kind { + ErrorKind::BudgetExceeded { .. } => None, + ErrorKind::PriorBudgetExceeded { .. } => None, + ErrorKind::Handle(e) => Some(e), } } +} impl From for InEvalError { fn from(value: HandleError) -> Self { diff --git a/all-is-cubes/src/character.rs b/all-is-cubes/src/character.rs index 8367caa9c..68300b23a 100644 --- a/all-is-cubes/src/character.rs +++ b/all-is-cubes/src/character.rs @@ -848,26 +848,26 @@ pub enum CharacterTransactionConflict { Behaviors(behavior::BehaviorTransactionConflict), } - impl core::error::Error for CharacterTransactionMismatch { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - CharacterTransactionMismatch::Body(e) => Some(e), - CharacterTransactionMismatch::Inventory(e) => Some(e), - CharacterTransactionMismatch::Behaviors(e) => Some(e), - } +impl core::error::Error for CharacterTransactionMismatch { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + CharacterTransactionMismatch::Body(e) => Some(e), + CharacterTransactionMismatch::Inventory(e) => Some(e), + CharacterTransactionMismatch::Behaviors(e) => Some(e), } } +} - impl core::error::Error for CharacterTransactionConflict { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - CharacterTransactionConflict::SetSpace => None, - CharacterTransactionConflict::Body(_) => None, - CharacterTransactionConflict::Inventory(e) => Some(e), - CharacterTransactionConflict::Behaviors(e) => Some(e), - } +impl core::error::Error for CharacterTransactionConflict { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + CharacterTransactionConflict::SetSpace => None, + CharacterTransactionConflict::Body(_) => None, + CharacterTransactionConflict::Inventory(e) => Some(e), + CharacterTransactionConflict::Behaviors(e) => Some(e), } } +} /// Description of a change to a [`Character`] for use in listeners. #[derive(Clone, Debug, Eq, Hash, PartialEq)] diff --git a/all-is-cubes/src/inv/inventory.rs b/all-is-cubes/src/inv/inventory.rs index 3bd900063..5116f5b8f 100644 --- a/all-is-cubes/src/inv/inventory.rs +++ b/all-is-cubes/src/inv/inventory.rs @@ -493,8 +493,8 @@ pub enum InventoryConflict { ReplaceSameSlot { slot: usize }, } - impl core::error::Error for InventoryMismatch {} - impl core::error::Error for InventoryConflict {} +impl core::error::Error for InventoryMismatch {} +impl core::error::Error for InventoryConflict {} /// Description of a change to an [`Inventory`] for use in listeners. #[derive(Clone, Debug, Eq, Hash, PartialEq)] diff --git a/all-is-cubes/src/op.rs b/all-is-cubes/src/op.rs index 09cf8d34d..ec8b92d9c 100644 --- a/all-is-cubes/src/op.rs +++ b/all-is-cubes/src/op.rs @@ -288,15 +288,15 @@ pub(crate) enum OperationError { OutOfBounds { operation: GridAab, space: GridAab }, } - impl core::error::Error for OperationError { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - Self::InternalConflict(e) => Some(e), - Self::Unmatching => None, - Self::OutOfBounds {..} => None, - } +impl core::error::Error for OperationError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + Self::InternalConflict(e) => Some(e), + Self::Unmatching => None, + Self::OutOfBounds { .. } => None, } } +} #[cfg(test)] mod tests { diff --git a/all-is-cubes/src/physics/body.rs b/all-is-cubes/src/physics/body.rs index 03228b3fa..44a676748 100644 --- a/all-is-cubes/src/physics/body.rs +++ b/all-is-cubes/src/physics/body.rs @@ -750,12 +750,11 @@ impl transaction::Merge for BodyTransaction { #[non_exhaustive] pub enum BodyMismatch {} - impl core::error::Error for BodyMismatch { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match *self { - } - } +impl core::error::Error for BodyMismatch { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match *self {} } +} /// Note: Tests which involve both body and collision code are currently in the parent module. #[cfg(test)] diff --git a/all-is-cubes/src/space/space_txn.rs b/all-is-cubes/src/space/space_txn.rs index 72fabfc9a..a51ad4238 100644 --- a/all-is-cubes/src/space/space_txn.rs +++ b/all-is-cubes/src/space/space_txn.rs @@ -398,24 +398,23 @@ pub enum SpaceTransactionConflict { Behaviors(behavior::BehaviorTransactionConflict), } - impl core::error::Error for SpaceTransactionMismatch { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - SpaceTransactionMismatch::Cube(_) => None, - SpaceTransactionMismatch::OutOfBounds {.. } => None, - SpaceTransactionMismatch::Behaviors(mismatch) => Some(mismatch), - } +impl core::error::Error for SpaceTransactionMismatch { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + SpaceTransactionMismatch::Cube(_) => None, + SpaceTransactionMismatch::OutOfBounds { .. } => None, + SpaceTransactionMismatch::Behaviors(mismatch) => Some(mismatch), } } - impl core::error::Error for SpaceTransactionConflict { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - SpaceTransactionConflict::Cube { conflict, .. } => Some(conflict), - SpaceTransactionConflict::Behaviors(conflict) => Some(conflict), - } +} +impl core::error::Error for SpaceTransactionConflict { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + SpaceTransactionConflict::Cube { conflict, .. } => Some(conflict), + SpaceTransactionConflict::Behaviors(conflict) => Some(conflict), } } - +} impl fmt::Display for SpaceTransactionMismatch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/all-is-cubes/src/universe/handle.rs b/all-is-cubes/src/universe/handle.rs index 1bd29bf21..c33c05927 100644 --- a/all-is-cubes/src/universe/handle.rs +++ b/all-is-cubes/src/universe/handle.rs @@ -526,8 +526,7 @@ pub enum HandleError { NotReady(Name), } - - impl core::error::Error for HandleError {} +impl core::error::Error for HandleError {} /// Read access to the referent of a [`Handle`]. /// diff --git a/all-is-cubes/src/universe/universe_txn.rs b/all-is-cubes/src/universe/universe_txn.rs index e1ebdc7d4..4c75cccf2 100644 --- a/all-is-cubes/src/universe/universe_txn.rs +++ b/all-is-cubes/src/universe/universe_txn.rs @@ -258,24 +258,25 @@ pub enum UniverseConflict { Behaviors(behavior::BehaviorTransactionConflict), } - impl core::error::Error for UniverseMismatch { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - UniverseMismatch::DifferentUniverse {..} => None, - UniverseMismatch::Member(mc) => Some(&mc.mismatch), - UniverseMismatch::Behaviors(c) => Some(c), - UniverseMismatch::InvalidPending => None, - } +impl core::error::Error for UniverseMismatch { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + UniverseMismatch::DifferentUniverse { .. } => None, + UniverseMismatch::Member(mc) => Some(&mc.mismatch), + UniverseMismatch::Behaviors(c) => Some(c), + UniverseMismatch::InvalidPending => None, } - } impl core::error::Error for UniverseConflict { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - UniverseConflict::DifferentUniverse(_, _) => None, - UniverseConflict::Member(mc) => Some(&mc.conflict), - UniverseConflict::Behaviors(c) => Some(c), - } + } +} +impl core::error::Error for UniverseConflict { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + UniverseConflict::DifferentUniverse(_, _) => None, + UniverseConflict::Member(mc) => Some(&mc.conflict), + UniverseConflict::Behaviors(c) => Some(c), } } +} impl fmt::Display for UniverseMismatch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -861,15 +862,15 @@ pub enum MemberConflict { Modify(ModifyMemberConflict), } - impl core::error::Error for MemberConflict { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - match self { - MemberConflict::InsertVsOther => None, - MemberConflict::DeleteVsOther => None, - MemberConflict::Modify(e) => e.source(), - } +impl core::error::Error for MemberConflict { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + MemberConflict::InsertVsOther => None, + MemberConflict::DeleteVsOther => None, + MemberConflict::Modify(e) => e.source(), } } +} /// Transaction precondition error type for a single member in a [`UniverseTransaction`]. #[derive(Clone, Debug, Eq, PartialEq, displaydoc::Display)] @@ -918,16 +919,16 @@ pub struct ModifyMemberMismatch(AnyTransactionMismatch); #[derive(Clone, Debug, Eq, PartialEq)] pub struct ModifyMemberConflict(AnyTransactionConflict); - impl core::error::Error for ModifyMemberMismatch { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - self.0.source() - } +impl core::error::Error for ModifyMemberMismatch { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + self.0.source() } - impl core::error::Error for ModifyMemberConflict { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - self.0.source() - } +} +impl core::error::Error for ModifyMemberConflict { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + self.0.source() } +} impl fmt::Display for ModifyMemberMismatch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {