pub struct Arena<I: ArenaIndex, T: 'static, A: Allocator = Global> { /* private fields */ }Expand description
Unordered container with random access.
Implementations§
Source§impl<I: ArenaIndex, T> Arena<I, T, Global>
impl<I: ArenaIndex, T> Arena<I, T, Global>
Sourcepub fn into_raw_parts(self) -> (usize, usize, usize, I::Optional)
pub fn into_raw_parts(self) -> (usize, usize, usize, I::Optional)
Decomposes Arena into raw components.
Use from_raw_parts to assemble Arena back.
Sourcepub unsafe fn from_raw_parts(
a: usize,
b: usize,
c: usize,
d: I::Optional,
) -> Self
pub unsafe fn from_raw_parts( a: usize, b: usize, c: usize, d: I::Optional, ) -> Self
Creates an Arena from raw parts.
§Safety
Raw parts must be obtained using into_raw_parts method
of same type.
Source§impl<I: ArenaIndex, T, A: Allocator> Arena<I, T, A>
impl<I: ArenaIndex, T, A: Allocator> Arena<I, T, A>
Sourcepub fn into_raw_parts_with_alloc(self) -> (usize, usize, usize, I::Optional, A)
pub fn into_raw_parts_with_alloc(self) -> (usize, usize, usize, I::Optional, A)
Decomposes Arena into raw components including allocator.
Use from_raw_parts_in to assemble Arena back.
Sourcepub unsafe fn from_raw_parts_in(
a: usize,
b: usize,
c: usize,
d: I::Optional,
alloc: A,
) -> Self
pub unsafe fn from_raw_parts_in( a: usize, b: usize, c: usize, d: I::Optional, alloc: A, ) -> Self
Creates an Arena from raw parts including allocator.
§Safety
Raw parts must be obtained using into_raw_parts_with_alloc method
of same type.
Sourcepub const fn new() -> Selfwhere
A: ConstDefault,
pub const fn new() -> Selfwhere
A: ConstDefault,
Creates an arena instance.
Sourcepub fn with_capacity(capacity: usize) -> Selfwhere
A: ConstDefault,
pub fn with_capacity(capacity: usize) -> Selfwhere
A: ConstDefault,
Creates an arena instance with the specified initial capacity.
Sourcepub fn with_capacity_in(capacity: usize, alloc: A) -> Self
pub fn with_capacity_in(capacity: usize, alloc: A) -> Self
Creates an arena instance with the specified initial capacity.
Sourcepub fn into_items(self) -> ArenaItems<I, T, A>
pub fn into_items(self) -> ArenaItems<I, T, A>
Returns contained items packed in a special container. While arena itself is unique (i.e. non-clonable) object, this special container could be cloned.
Sourcepub fn items(&self) -> &ArenaItems<I, T, A>
pub fn items(&self) -> &ArenaItems<I, T, A>
Returns reference to contained items packed in a special container. While arena itself is unique (i.e. non-clonable) object, this special container could be cloned.
Sourcepub fn items_mut(&mut self) -> &mut ArenaItems<I, T, A>
pub fn items_mut(&mut self) -> &mut ArenaItems<I, T, A>
Returns mutable reference to contained items packed in a (mostly read-only) special container. While arena itself is unique (i.e. non-clonable) object, this special container could be cloned.
Sourcepub fn reserve(&mut self)
pub fn reserve(&mut self)
Reserves capacity for at least one more element.
The collection may reserve more space to avoid frequent reallocations.
After calling reserve, capacity will be greater than or equal to
self.items().len() + 1. Does nothing if capacity is already sufficient.
§Panics
Panics if the required capacity overflows maximum index value + 1.
Sourcepub fn reserve_exact(&mut self)
pub fn reserve_exact(&mut self)
Reserves the minimum capacity for exactly one more element.
After calling reserve_exact, capacity will be greater than or equal to
self.items().len() + 1. Does nothing if the capacity is already sufficient.
Note that the allocator may give the collection more space than it requests.
Therefore, capacity can not be relied upon to be precisely minimal.
Prefer reserve if future insertions are expected.
§Panics
Panics if the required capacity overflows maximum index value + 1.
Sourcepub fn try_reserve(&mut self) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self) -> Result<(), TryReserveError>
Tries to reserve capacity for at least one more element.
The collection may reserve more space to avoid frequent reallocations.
After calling try_reserve, capacity will be greater than or equal
to self.items().len() + 1. Does nothing if capacity is already sufficient.
§Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Sourcepub fn try_reserve_exact(&mut self) -> Result<(), TryReserveError>
pub fn try_reserve_exact(&mut self) -> Result<(), TryReserveError>
Tries to reserve capacity for exactly one more element.
The collection may reserve more space to avoid frequent reallocations.
After calling try_reserve_exact, capacity will be greater than or equal
to self.items().len() + 1. Does nothing if capacity is already sufficient.
Note that the allocator may give the collection more space than it requests.
Therefore, capacity can not be relied upon to be precisely minimal.
Prefer try_reserve if future insertions are expected.
§Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Trait Implementations§
Source§impl<I: Debug + ArenaIndex, T: Debug + 'static, A: Debug + Allocator> Debug for Arena<I, T, A>
impl<I: Debug + ArenaIndex, T: Debug + 'static, A: Debug + Allocator> Debug for Arena<I, T, A>
Source§impl<I: ArenaIndex, T, A> Default for Arena<I, T, A>where
A: ConstDefault + Allocator,
impl<I: ArenaIndex, T, A> Default for Arena<I, T, A>where
A: ConstDefault + Allocator,
Auto Trait Implementations§
impl<I, T, A> Freeze for Arena<I, T, A>
impl<I, T, A> RefUnwindSafe for Arena<I, T, A>
impl<I, T, A> Send for Arena<I, T, A>
impl<I, T, A> Sync for Arena<I, T, A>
impl<I, T, A> Unpin for Arena<I, T, A>
impl<I, T, A> UnsafeUnpin for Arena<I, T, A>
impl<I, T, A> UnwindSafe for Arena<I, T, A>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more