Skip to content

Commit

Permalink
use ptr::eq and ptr::hash
Browse files Browse the repository at this point in the history
  • Loading branch information
maniwani committed Feb 20, 2023
1 parent daaaed9 commit 727184b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions crates/bevy_ecs/src/schedule/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
pub trait ScheduleLabel: DynHash + Debug + Send + Sync + 'static {}

/// A lightweight and printable identifier for a [`Schedule`](super::Schedule).
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
#[derive(Clone, Copy, Eq)]
pub struct ScheduleId(&'static str);

impl ScheduleId {
Expand All @@ -62,6 +62,18 @@ impl ScheduleId {
}
}

impl PartialEq for ScheduleId {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self.0, other.0)
}
}

impl Hash for ScheduleId {
fn hash<H: Hasher>(&self, state: &mut H) {
std::ptr::hash(self.0, state);
}
}

impl Debug for ScheduleId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
Expand Down Expand Up @@ -98,7 +110,7 @@ pub trait SystemSet: DynHash + Debug + Send + Sync + 'static {
}

/// A lightweight and printable identifier for a [`SystemSet`].
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
#[derive(Clone, Copy, Eq)]
pub struct SystemSetId(&'static str);

impl SystemSetId {
Expand All @@ -109,6 +121,18 @@ impl SystemSetId {
}
}

impl PartialEq for SystemSetId {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self.0, other.0)
}
}

impl Hash for SystemSetId {
fn hash<H: Hasher>(&self, state: &mut H) {
std::ptr::hash(self.0, state);
}
}

impl Debug for SystemSetId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
Expand Down

0 comments on commit 727184b

Please sign in to comment.