pub trait Slab {
// Required methods
fn len(&self) -> usize;
fn read_unchecked<T>(&self, id: Id<T>) -> T
where T: SlabItem;
fn write_indexed<T>(&mut self, t: &T, index: usize) -> usize
where T: SlabItem;
fn write_indexed_slice<T>(&mut self, t: &[T], index: usize) -> usize
where T: SlabItem;
// Provided methods
fn contains<T>(&self, id: Id<T>) -> bool
where T: SlabItem { ... }
fn read<T>(&self, id: Id<T>) -> T
where T: SlabItem + Default { ... }
fn read_vec<T>(&self, array: Array<T>) -> Vec<T>
where T: SlabItem + Default { ... }
fn write<T>(&mut self, id: Id<T>, t: &T)
where T: SlabItem { ... }
fn write_array<T>(&mut self, array: Array<T>, data: &[T])
where T: SlabItem { ... }
}Expand description
Trait for slabs of u32s that can store many types.
Required Methodsยง
Sourcefn read_unchecked<T>(&self, id: Id<T>) -> Twhere
T: SlabItem,
fn read_unchecked<T>(&self, id: Id<T>) -> Twhere
T: SlabItem,
Read the type from the slab using the Id as the index.
Provided Methodsยง
Sourcefn contains<T>(&self, id: Id<T>) -> boolwhere
T: SlabItem,
fn contains<T>(&self, id: Id<T>) -> boolwhere
T: SlabItem,
Returns whether the slab may contain the value with the given id.
Sourcefn read<T>(&self, id: Id<T>) -> T
fn read<T>(&self, id: Id<T>) -> T
Read the type from the slab using the Id as the index, or return
the default if id is Id::NONE.
fn read_vec<T>(&self, array: Array<T>) -> Vec<T>
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.