pub struct Arena<T> { /* private fields */ }Expand description
A generational arena: dense storage with reuse of freed slots and stale-handle detection. 代际 arena:密集存储,支持空闲槽位复用与过期句柄检测。
This is the ownership primitive behind meshes, textures, and render objects. 这是网格、纹理和渲染对象背后的所有权原语。 It is intentionally a small self-contained type so it can be swapped for an external slot map without touching call sites. 它刻意做成一个小而自包含的类型,以便可以在不改动调用方的情况下替换为外部的槽位映射。
Implementations§
Source§impl<T> Arena<T>
impl<T> Arena<T>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn get(&self, id: Id<T>) -> Option<&T>
pub fn get_mut(&mut self, id: Id<T>) -> Option<&mut T>
pub fn contains(&self, id: Id<T>) -> bool
Sourcepub fn remove(&mut self, id: Id<T>) -> Option<T>
pub fn remove(&mut self, id: Id<T>) -> Option<T>
Remove a value, invalidating the handle. 移除一个值,并使该句柄失效。
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Arena<T>
impl<T> RefUnwindSafe for Arena<T>where
Vec<Slot<T>>: RefUnwindSafe,
impl<T> Send for Arena<T>
impl<T> Sync for Arena<T>
impl<T> Unpin for Arena<T>
impl<T> UnsafeUnpin for Arena<T>where
Vec<Slot<T>>: UnsafeUnpin,
impl<T> UnwindSafe for Arena<T>where
Vec<Slot<T>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more