diff --git a/crates/bevy_ecs/src/world/identifier.rs b/crates/bevy_ecs/src/world/identifier.rs index 6e2b8efc0f222..c65da1b81a7e1 100644 --- a/crates/bevy_ecs/src/world/identifier.rs +++ b/crates/bevy_ecs/src/world/identifier.rs @@ -1,6 +1,7 @@ +use crate::storage::SparseSetIndex; use std::sync::atomic::{AtomicUsize, Ordering}; -#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] // We use usize here because that is the largest `Atomic` we want to require /// A unique identifier for a [`super::World`]. // Note that this *is* used by external crates as well as for internal safety checks @@ -26,6 +27,17 @@ impl WorldId { } } +impl SparseSetIndex for WorldId { + #[inline] + fn sparse_set_index(&self) -> usize { + self.0 + } + + fn get_sparse_set_index(value: usize) -> Self { + Self(value) + } +} + #[cfg(test)] mod tests { use super::*;