diff --git a/crates/bevy_ui/Cargo.toml b/crates/bevy_ui/Cargo.toml index 2ee274d4ba..87304ac959 100644 --- a/crates/bevy_ui/Cargo.toml +++ b/crates/bevy_ui/Cargo.toml @@ -36,7 +36,11 @@ bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } taffy = { version = "0.5" } serde = { version = "1", features = ["derive"], optional = true } bytemuck = { version = "1.5", features = ["derive"] } -thiserror = "1.0.0" +derive_more = { version = "1", default-features = false, features = [ + "error", + "from", + "display", +] } nonmax = "0.5" smallvec = "1.11" diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index 1f7a5a02d9..83850b7e19 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -1,7 +1,7 @@ use bevy_math::Vec2; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use core::ops::{Div, DivAssign, Mul, MulAssign, Neg}; -use thiserror::Error; +use derive_more::derive::{Display, Error}; #[cfg(feature = "serialize")] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; @@ -175,11 +175,11 @@ impl Neg for Val { } } -#[derive(Debug, Eq, PartialEq, Clone, Copy, Error)] +#[derive(Debug, Eq, PartialEq, Clone, Copy, Error, Display)] pub enum ValArithmeticError { - #[error("the variants of the Vals don't match")] + #[display("the variants of the Vals don't match")] NonIdenticalVariants, - #[error("the given variant of Val is not evaluateable (non-numeric)")] + #[display("the given variant of Val is not evaluateable (non-numeric)")] NonEvaluateable, } diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 3e418c689d..5b7709c42f 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -18,7 +18,7 @@ use bevy_sprite::BorderRect; use bevy_transform::components::Transform; use bevy_utils::tracing::warn; use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; -use thiserror::Error; +use derive_more::derive::{Display, Error, From}; use ui_surface::UiSurface; #[cfg(feature = "bevy_text")] @@ -61,12 +61,12 @@ impl Default for LayoutContext { } } -#[derive(Debug, Error)] +#[derive(Debug, Error, Display, From)] pub enum LayoutError { - #[error("Invalid hierarchy")] + #[display("Invalid hierarchy")] InvalidHierarchy, - #[error("Taffy error: {0}")] - TaffyError(#[from] taffy::TaffyError), + #[display("Taffy error: {_0}")] + TaffyError(taffy::TaffyError), } #[doc(hidden)] diff --git a/crates/bevy_ui/src/ui_material.rs b/crates/bevy_ui/src/ui_material.rs index 4c5a788d2f..b57e65865e 100644 --- a/crates/bevy_ui/src/ui_material.rs +++ b/crates/bevy_ui/src/ui_material.rs @@ -8,6 +8,7 @@ use bevy_render::{ extract_component::ExtractComponent, render_resource::{AsBindGroup, RenderPipelineDescriptor, ShaderRef}, }; +use derive_more::derive::From; /// Materials are used alongside [`UiMaterialPlugin`](crate::UiMaterialPlugin) and [`MaterialNodeBundle`](crate::prelude::MaterialNodeBundle) /// to spawn entities that are rendered with a specific [`UiMaterial`] type. They serve as an easy to use high level @@ -152,7 +153,9 @@ where } } -#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, ExtractComponent)] +#[derive( + Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, ExtractComponent, From, +)] #[reflect(Component, Default)] pub struct UiMaterialHandle(pub Handle); @@ -162,12 +165,6 @@ impl Default for UiMaterialHandle { } } -impl From> for UiMaterialHandle { - fn from(handle: Handle) -> Self { - Self(handle) - } -} - impl From> for AssetId { fn from(material: UiMaterialHandle) -> Self { material.id() diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 63cc8038ca..25f9559b89 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -12,8 +12,8 @@ use bevy_sprite::BorderRect; use bevy_utils::warn_once; use bevy_window::{PrimaryWindow, WindowRef}; use core::num::NonZero; +use derive_more::derive::{Display, Error, From}; use smallvec::SmallVec; -use thiserror::Error; /// Base component for a UI node, which also provides the computed size of the node. /// @@ -1333,7 +1333,7 @@ impl Default for GridTrack { } } -#[derive(Copy, Clone, PartialEq, Debug, Reflect)] +#[derive(Copy, Clone, PartialEq, Debug, Reflect, From)] #[reflect(Default, PartialEq)] #[cfg_attr( feature = "serialize", @@ -1363,12 +1363,6 @@ impl Default for GridTrackRepetition { } } -impl From for GridTrackRepetition { - fn from(count: u16) -> Self { - Self::Count(count) - } -} - impl From for GridTrackRepetition { fn from(count: i32) -> Self { Self::Count(count as u16) @@ -1784,11 +1778,11 @@ fn try_into_grid_span(span: u16) -> Result>, GridPlacementEr } /// Errors that occur when setting constraints for a `GridPlacement` -#[derive(Debug, Eq, PartialEq, Clone, Copy, Error)] +#[derive(Debug, Eq, PartialEq, Clone, Copy, Error, Display)] pub enum GridPlacementError { - #[error("Zero is not a valid grid position")] + #[display("Zero is not a valid grid position")] InvalidZeroIndex, - #[error("Spans cannot be zero length")] + #[display("Spans cannot be zero length")] InvalidZeroSpan, }