diff --git a/crates/valence_core/src/text.rs b/crates/valence_core/src/text.rs index 20982a207..abc2046bb 100644 --- a/crates/valence_core/src/text.rs +++ b/crates/valence_core/src/text.rs @@ -628,13 +628,13 @@ impl Deref for Text { type Target = TextInner; fn deref(&self) -> &Self::Target { - &*self.0 + &self.0 } } impl DerefMut for Text { fn deref_mut(&mut self) -> &mut Self::Target { - &mut *self.0 + &mut self.0 } } diff --git a/crates/valence_core/src/text/color.rs b/crates/valence_core/src/text/color.rs index 3baaa9ff3..16d51652a 100644 --- a/crates/valence_core/src/text/color.rs +++ b/crates/valence_core/src/text/color.rs @@ -1,13 +1,14 @@ //! [`Color`] and related data structures. use std::fmt; +use std::hash::Hash; use serde::de::Visitor; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; /// Text color -#[derive(Default, Debug, PartialOrd, Eq, Ord, Clone, Copy, Hash)] +#[derive(Default, Debug, PartialOrd, Eq, Ord, Clone, Copy)] pub enum Color { /// The default color for the text will be used, which varies by context /// (in some cases, it's white; in others, it's black; in still others, it @@ -145,6 +146,22 @@ impl PartialEq for Color { } } +impl Hash for Color { + fn hash(&self, state: &mut H) { + match self { + Self::Reset => state.write_u8(0), + Self::Rgb(rgb) => { + state.write_u8(1); + rgb.hash(state); + } + Self::Normal(normal) => { + state.write_u8(1); + RgbColor::from(*normal).hash(state); + } + } + } +} + impl From for RgbColor { fn from(value: NormalColor) -> Self { match value {