pub trait RawStorage {
type Item;
// Required methods
unsafe fn get(&self, index: Index) -> &Self::Item;
unsafe fn get_mut(&self, index: Index) -> &mut Self::Item;
unsafe fn insert(&mut self, index: Index, value: Self::Item);
unsafe fn remove(&mut self, index: Index) -> Self::Item;
}Expand description
A trait for storing components in memory based on low valued indexes.
Is not required to keep track of whether the component is present or not for a given index, it
is up to the user of a RawStorage to keep track of this.
Because of this, a type that implements RawStorage is allowed to leak all component values
on drop. In order to prevent this, the storage must have only empty indexes at the time of
drop.
Required Associated Types§
Required Methods§
Sourceunsafe fn get(&self, index: Index) -> &Self::Item
unsafe fn get(&self, index: Index) -> &Self::Item
Return a reference to the component at the given index.
You must only call get with index values that are non-empty (have been previously had
components inserted with insert).
Sourceunsafe fn get_mut(&self, index: Index) -> &mut Self::Item
unsafe fn get_mut(&self, index: Index) -> &mut Self::Item
Return a mutable reference to the component at the given index.
You must only call get_mut with index values that are non-empty (have been previously
had components inserted with insert).
Returns a mutable reference to the previously inserted component. You must follow Rust’s aliasing rules here, so you must not call this method if there is any other live reference to the same component.