Trait specs::storage::DistinctStorage
source · [−]pub unsafe trait DistinctStorage { }
Expand description
This is a marker trait which requires you to uphold the following guarantee:
Multiple threads may call
get_mut()
with distinct indices without causing > undefined behavior.
This is for example valid for Vec
:
vec![1, 2, 3];
We may modify both element 1 and 2 at the same time; indexing the vector mutably does not modify anything else than the respective elements.
As a counter example, we may have some kind of cached storage; it caches
elements when they’re retrieved, so pushes a new element to some
cache-vector. This storage is not allowed to implement DistinctStorage
.
Implementing this trait marks the storage safe for concurrent mutation (of
distinct elements), thus allows join_par()
.
Implementors
impl<'a> DistinctStorage for AntiStorage<'a>
impl<'a, T: Component, D> DistinctStorage for Storage<'a, T, D> where
T::Storage: DistinctStorage,
impl<T> DistinctStorage for DefaultVecStorage<T>
impl<T> DistinctStorage for DenseVecStorage<T>
impl<T> DistinctStorage for HashMapStorage<T>
impl<T> DistinctStorage for NullStorage<T>
This is safe because you cannot mutate ZSTs.