Skip to content

Commit

Permalink
Remove thiserror from bevy_color (#15777)
Browse files Browse the repository at this point in the history
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_color`
  • Loading branch information
bushrat011899 authored Oct 9, 2024
1 parent 1be0ed3 commit 284e36a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 68 deletions.
6 changes: 5 additions & 1 deletion crates/bevy_color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
], optional = true }
bytemuck = { version = "1", features = ["derive"] }
serde = { version = "1.0", features = ["derive"], optional = true }
thiserror = "1.0"
derive_more = { version = "1", default-features = false, features = [
"error",
"from",
"display",
] }
wgpu-types = { version = "22", default-features = false, optional = true }
encase = { version = "0.10", default-features = false }

Expand Down
63 changes: 2 additions & 61 deletions crates/bevy_color/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
};
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::prelude::*;
use derive_more::derive::From;

/// An enumerated type that can represent any of the color types in this crate.
///
Expand Down Expand Up @@ -40,7 +41,7 @@ use bevy_reflect::prelude::*;
/// due to its perceptual uniformity and broad support for Bevy's color operations.
/// To avoid the cost of repeated conversion, and ensure consistent results where that is desired,
/// first convert this [`Color`] into your desired color space.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, From)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(PartialEq, Default))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
Expand Down Expand Up @@ -426,66 +427,6 @@ impl Alpha for Color {
}
}

impl From<Srgba> for Color {
fn from(value: Srgba) -> Self {
Self::Srgba(value)
}
}

impl From<LinearRgba> for Color {
fn from(value: LinearRgba) -> Self {
Self::LinearRgba(value)
}
}

impl From<Hsla> for Color {
fn from(value: Hsla) -> Self {
Self::Hsla(value)
}
}

impl From<Hsva> for Color {
fn from(value: Hsva) -> Self {
Self::Hsva(value)
}
}

impl From<Hwba> for Color {
fn from(value: Hwba) -> Self {
Self::Hwba(value)
}
}

impl From<Oklaba> for Color {
fn from(value: Oklaba) -> Self {
Self::Oklaba(value)
}
}

impl From<Oklcha> for Color {
fn from(value: Oklcha) -> Self {
Self::Oklcha(value)
}
}

impl From<Lcha> for Color {
fn from(value: Lcha) -> Self {
Self::Lcha(value)
}
}

impl From<Laba> for Color {
fn from(value: Laba) -> Self {
Self::Laba(value)
}
}

impl From<Xyza> for Color {
fn from(value: Xyza) -> Self {
Self::Xyza(value)
}
}

impl From<Color> for Srgba {
fn from(value: Color) -> Self {
match value {
Expand Down
13 changes: 7 additions & 6 deletions crates/bevy_color/src/srgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use bevy_math::{ops, Vec3, Vec4};
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::prelude::*;
use thiserror::Error;
use derive_more::derive::{Display, Error, From};

/// Non-linear standard RGB with alpha.
#[doc = include_str!("../docs/conversion.md")]
Expand Down Expand Up @@ -421,16 +421,17 @@ impl From<Srgba> for Xyza {
}

/// Error returned if a hex string could not be parsed as a color.
#[derive(Debug, Error, PartialEq, Eq)]
#[derive(Debug, Error, Display, PartialEq, Eq, From)]
pub enum HexColorError {
/// Parsing error.
#[error("Invalid hex string")]
Parse(#[from] core::num::ParseIntError),
#[display("Invalid hex string")]
Parse(core::num::ParseIntError),
/// Invalid length.
#[error("Unexpected length of hex string")]
#[display("Unexpected length of hex string")]
Length,
/// Invalid character.
#[error("Invalid hex char")]
#[display("Invalid hex char")]
#[error(ignore)]
Char(char),
}

Expand Down

0 comments on commit 284e36a

Please sign in to comment.