Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Sep 5, 2024
1 parent db2a654 commit bfb7492
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 86 deletions.
2 changes: 1 addition & 1 deletion all-is-cubes-ui/src/vui/widget_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion all-is-cubes-ui/src/vui/widgets/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ impl vui::WidgetController for ProgressBarController {
fn step(
&mut self,
_context: &vui::WidgetContext<'_>,
) -> Result<(vui::WidgetTransaction, vui::Then), Box<dyn core::error::Error + Send + Sync>> {
) -> Result<(vui::WidgetTransaction, vui::Then), Box<dyn core::error::Error + Send + Sync>>
{
if !self.todo.get_and_clear() {
return Ok((SpaceTransaction::default(), vui::Then::Step));
}
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions all-is-cubes/src/block/eval/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HandleError> for InEvalError {
fn from(value: HandleError) -> Self {
Expand Down
30 changes: 15 additions & 15 deletions all-is-cubes/src/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/inv/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
14 changes: 7 additions & 7 deletions all-is-cubes/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions all-is-cubes/src/physics/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
27 changes: 13 additions & 14 deletions all-is-cubes/src/space/space_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions all-is-cubes/src/universe/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down
61 changes: 31 additions & 30 deletions all-is-cubes/src/universe/universe_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bfb7492

Please sign in to comment.