Skip to content

Commit

Permalink
clippy error and warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PonasKovas committed Jul 18, 2023
1 parent 18dbcbd commit 7268a42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/valence_core/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
19 changes: 18 additions & 1 deletion crates/valence_core/src/text/color.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -145,6 +146,22 @@ impl PartialEq for Color {
}
}

impl Hash for Color {
fn hash<H: std::hash::Hasher>(&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<NormalColor> for RgbColor {
fn from(value: NormalColor) -> Self {
match value {
Expand Down

0 comments on commit 7268a42

Please sign in to comment.