pub struct ImmutableArrayBuilder<T: Sized, TAllocator = StdAllocator>where
TAllocator: Allocator,{ /* private fields */ }
Expand description
A builder for ImmutableArray
.
§Notes
This struct is very similar to a mutable vec. It is used to construct
ImmutableArray
incrementally, in place.
Implementations§
Source§impl<T: Sized, TAllocator: Allocator> ImmutableArrayBuilder<T, TAllocator>
impl<T: Sized, TAllocator: Allocator> ImmutableArrayBuilder<T, TAllocator>
Sourcepub fn shrink_to_fit(&mut self) -> Result<(), ArrayConstructionError>
pub fn shrink_to_fit(&mut self) -> Result<(), ArrayConstructionError>
Shrinks current capacity to the length.
§Notes
This method reallocates entire buffer if the current capacity is greater than the length.
§Errors
For details see ArrayConstructionError
.
Sourcepub fn build(self) -> ImmutableArray<T, TAllocator>
pub fn build(self) -> ImmutableArray<T, TAllocator>
Builds the ImmutableArray
from the builder.
§Notes
This method is basically free. It is here only to move ownership from mutable builder to immutable array.
Sourcepub fn new() -> Result<Self, ArrayConstructionError>
pub fn new() -> Result<Self, ArrayConstructionError>
Sourcepub fn with_allocator(
allocator: TAllocator,
) -> Result<Self, ArrayConstructionError>
pub fn with_allocator( allocator: TAllocator, ) -> Result<Self, ArrayConstructionError>
Sourcepub fn push(&mut self, value: T) -> Result<(), ArrayConstructionError>
pub fn push(&mut self, value: T) -> Result<(), ArrayConstructionError>
Sourcepub fn extend_from_array<const N: usize>(
&mut self,
values: [T; N],
) -> Result<(), ArrayConstructionError>
pub fn extend_from_array<const N: usize>( &mut self, values: [T; N], ) -> Result<(), ArrayConstructionError>
pub const fn len(&self) -> Length
pub const fn capacity(&self) -> Length
Source§impl<T: Sized + Clone, TAllocator: Allocator> ImmutableArrayBuilder<T, TAllocator>
impl<T: Sized + Clone, TAllocator: Allocator> ImmutableArrayBuilder<T, TAllocator>
Sourcepub fn extend_from_slice(
&mut self,
slice: &[T],
) -> Result<(), ArrayConstructionError>
pub fn extend_from_slice( &mut self, slice: &[T], ) -> Result<(), ArrayConstructionError>
Extends the builder with the specified slice.
§Notes
This method will clone each element one by one.
§Errors
For details see ArrayConstructionError
.
Trait Implementations§
Auto Trait Implementations§
impl<T, TAllocator> Freeze for ImmutableArrayBuilder<T, TAllocator>
impl<T, TAllocator> RefUnwindSafe for ImmutableArrayBuilder<T, TAllocator>where
<TAllocator as Allocator>::TAllocatedMemory: RefUnwindSafe,
TAllocator: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, TAllocator> Send for ImmutableArrayBuilder<T, TAllocator>
impl<T, TAllocator> Sync for ImmutableArrayBuilder<T, TAllocator>
impl<T, TAllocator> Unpin for ImmutableArrayBuilder<T, TAllocator>
impl<T, TAllocator> UnwindSafe for ImmutableArrayBuilder<T, TAllocator>where
<TAllocator as Allocator>::TAllocatedMemory: UnwindSafe,
TAllocator: UnwindSafe,
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