Struct ImmutableArrayBuilder

Source
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>

Source

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.

Source

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.

Source

pub fn new() -> Result<Self, ArrayConstructionError>

Creates a new builder with the default allocator.

§Errors

For details see ArrayConstructionError.

Source

pub fn with_allocator( allocator: TAllocator, ) -> Result<Self, ArrayConstructionError>

Creates a new builder with the specified allocator.

§Errors

For details see ArrayConstructionError.

Source

pub fn push(&mut self, value: T) -> Result<(), ArrayConstructionError>

Pushes a new value to the end of the builder.

§Errors

For details see ArrayConstructionError.

Source

pub fn extend_from_array<const N: usize>( &mut self, values: [T; N], ) -> Result<(), ArrayConstructionError>

Extends the builder with the specified values.

§Errors

For details see ArrayConstructionError.

Source

pub const fn len(&self) -> Length

Source

pub const fn capacity(&self) -> Length

Source§

impl<T: Sized + Clone, TAllocator: Allocator> ImmutableArrayBuilder<T, TAllocator>

Source

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§

Source§

impl<T: Sized, TAllocator: Allocator> Drop for ImmutableArrayBuilder<T, TAllocator>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, TAllocator> Freeze for ImmutableArrayBuilder<T, TAllocator>
where <TAllocator as Allocator>::TAllocatedMemory: Freeze, TAllocator: Freeze,

§

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>
where T: Send + Sync,

§

impl<T, TAllocator> Sync for ImmutableArrayBuilder<T, TAllocator>
where T: Send + Sync,

§

impl<T, TAllocator> Unpin for ImmutableArrayBuilder<T, TAllocator>
where <TAllocator as Allocator>::TAllocatedMemory: Unpin, TAllocator: Unpin, T: Unpin,

§

impl<T, TAllocator> UnwindSafe for ImmutableArrayBuilder<T, TAllocator>
where <TAllocator as Allocator>::TAllocatedMemory: UnwindSafe, TAllocator: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.