mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
Implement SparseSetIndex
for WorldId
(#7125)
# Objective - Fixes #7124 ## Solution - Add Hash Derive on `WorldId` - Add `SparseSetIndex` impl
This commit is contained in:
parent
7df680bb0a
commit
0e9f80e00b
1 changed files with 13 additions and 1 deletions
|
@ -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::*;
|
||||
|
|
Loading…
Reference in a new issue