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,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 New Issue
Block a user