From ecd04c1b72595bb89d92b827487dacfdf55b8d0c Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Thu, 10 Oct 2024 01:29:26 +1100 Subject: [PATCH] Remove `thiserror` from `bevy_sprite` (#15763) # Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_sprite` --- crates/bevy_sprite/Cargo.toml | 6 +++++- crates/bevy_sprite/src/mesh2d/material.rs | 9 ++------- crates/bevy_sprite/src/texture_atlas_builder.rs | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index baf62b882da43..59ee9b8fe1de8 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -37,7 +37,11 @@ bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" } bytemuck = { version = "1", features = ["derive", "must_cast"] } fixedbitset = "0.5" guillotiere = "0.6.0" -thiserror = "1.0" +derive_more = { version = "1", default-features = false, features = [ + "error", + "from", + "display", +] } rectangle-pack = "0.4" bitflags = "2.3" radsort = "0.1" diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index d773c386ebddc..847a3104fcf90 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -36,6 +36,7 @@ use bevy_render::{ use bevy_transform::components::{GlobalTransform, Transform}; use bevy_utils::tracing::error; use core::{hash::Hash, marker::PhantomData}; +use derive_more::derive::From; use crate::{ DrawMesh2d, Mesh2d, Mesh2dPipeline, Mesh2dPipelineKey, RenderMesh2dInstances, @@ -209,7 +210,7 @@ pub trait Material2d: AsBindGroup + Asset + Clone + Sized { /// commands.spawn(Mesh2d(meshes.add(Circle::new(50.0)))); /// } /// ``` -#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq)] +#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, From)] #[reflect(Component, Default)] #[require(HasMaterial2d)] pub struct MeshMaterial2d(pub Handle); @@ -220,12 +221,6 @@ impl Default for MeshMaterial2d { } } -impl From> for MeshMaterial2d { - fn from(handle: Handle) -> Self { - Self(handle) - } -} - impl From> for AssetId { fn from(material: MeshMaterial2d) -> Self { material.id() diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index ddeea0723804f..e99dd20efc3f8 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -9,19 +9,19 @@ use bevy_utils::{ tracing::{debug, error, warn}, HashMap, }; +use derive_more::derive::{Display, Error}; use rectangle_pack::{ contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, }; -use thiserror::Error; use crate::{TextureAtlasLayout, TextureAtlasSources}; -#[derive(Debug, Error)] +#[derive(Debug, Error, Display)] pub enum TextureAtlasBuilderError { - #[error("could not pack textures into an atlas within the given bounds")] + #[display("could not pack textures into an atlas within the given bounds")] NotEnoughSpace, - #[error("added a texture with the wrong format in an atlas")] + #[display("added a texture with the wrong format in an atlas")] WrongFormat, }