Skip to content

Commit e2563db

Browse files
joseph-giogeieredgar
authored andcommitted
interned labels are labels
1 parent 2ae3bd4 commit e2563db

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

crates/bevy_ecs/src/schedule/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,6 @@ impl<S: SystemSet> IntoSystemSetConfig for S {
449449
}
450450
}
451451

452-
impl IntoSystemSetConfig for InternedSystemSet {
453-
fn into_config(self) -> SystemSetConfig {
454-
SystemSetConfig::new(self)
455-
}
456-
}
457-
458452
impl IntoSystemSetConfig for SystemSetConfig {
459453
fn into_config(self) -> Self {
460454
self

crates/bevy_ecs/src/schedule/set.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ pub trait SystemSet: DynHash + Debug + Send + Sync + 'static {
7676
}
7777
}
7878

79+
impl SystemSet for Interned<dyn SystemSet> {
80+
fn system_type(&self) -> Option<TypeId> {
81+
(**self).system_type()
82+
}
83+
84+
fn is_anonymous(&self) -> bool {
85+
(**self).is_anonymous()
86+
}
87+
88+
fn dyn_clone(&self) -> Box<dyn SystemSet> {
89+
(**self).dyn_clone()
90+
}
91+
92+
fn dyn_static_ref(&self) -> Option<&'static dyn SystemSet> {
93+
Some(self.0)
94+
}
95+
}
96+
7997
impl From<&dyn SystemSet> for Interned<dyn SystemSet> {
8098
fn from(value: &dyn SystemSet) -> Interned<dyn SystemSet> {
8199
SYSTEM_SET_INTERNER.intern(value)

crates/bevy_utils/src/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::HashSet;
2626
// This implements [`Copy`], [`Clone`], [`PartialEq`], [`Eq`] and [`Hash`] regardles of what `T`
2727
// implements, because it only uses the pointer to the value and not the value itself.
2828
// Therefore it MUST NEVER implement [`Borrow`](`std::borrow::Borrow`).
29-
pub struct Interned<T: ?Sized + 'static>(&'static T);
29+
pub struct Interned<T: ?Sized + 'static>(pub &'static T);
3030

3131
impl<T: ?Sized> Deref for Interned<T> {
3232
type Target = T;

crates/bevy_utils/src/label.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,29 @@ macro_rules! define_label {
142142
}
143143
}
144144

145+
impl $label_trait_name for ::bevy_utils::intern::Interned<dyn $label_trait_name> {
146+
fn inner_type_id(&self) -> ::std::any::TypeId {
147+
(**self).inner_type_id()
148+
}
149+
150+
fn dyn_clone(&self) -> Box<dyn $label_trait_name> {
151+
(**self).dyn_clone()
152+
}
153+
154+
/// Casts this value to a form where it can be compared with other type-erased values.
155+
fn as_dyn_eq(&self) -> &dyn ::bevy_utils::label::DynEq {
156+
(**self).as_dyn_eq()
157+
}
158+
159+
fn dyn_hash(&self, state: &mut dyn ::std::hash::Hasher) {
160+
(**self).dyn_hash(state)
161+
}
162+
163+
fn dyn_static_ref(&self) -> Option<&'static dyn $label_trait_name> {
164+
Some(self.0)
165+
}
166+
}
167+
145168
impl PartialEq for dyn $label_trait_name {
146169
fn eq(&self, other: &Self) -> bool {
147170
self.as_dyn_eq().dyn_eq(other.as_dyn_eq())

0 commit comments

Comments
 (0)