Skip to main content

ArrayBuilder

Struct ArrayBuilder 

Source
pub struct ArrayBuilder<T> { /* private fields */ }
Expand description

A simple growable buffer.

Upstream hands out ArraySlices aliasing the builder’s array; here the builder owns a Vec<T> and ranges are borrowed as plain slices.

Implementations§

Source§

impl<T> ArrayBuilder<T>

Source

pub const fn new() -> Self

Source

pub fn length(&self) -> usize

The number of items.

Source

pub fn capacity(&self) -> usize

The allocated capacity.

Source

pub fn add_item(&mut self, value: T)

Appends one item.

Source

pub fn clear(&mut self)

Removes every item, keeping the storage.

Source

pub fn reset(&mut self)

Drops the storage (C# arrayBuilder = default).

Source

pub fn as_span(&self) -> &[T]

The items.

Source

pub fn as_span_mut(&mut self) -> &mut [T]

The items, mutably.

Source

pub fn as_slice(&self, start: usize, length: usize) -> &[T]

length items starting at start.

Source

pub fn as_slice_to(&self, length: usize) -> &[T]

The first length items (the original’s AsSlice(length); its AsSlice() is as_span).

Source

pub fn as_slice_mut(&mut self, start: usize, length: usize) -> &mut [T]

length items starting at start, mutably.

Source§

impl<T: Clone + Default> ArrayBuilder<T>

Source

pub fn set_length(&mut self, value: usize)

Sets the number of items; new items are default values.

Source

pub fn add(&mut self, length: usize) -> &mut [T]

Appends length default items and returns them.

Source

pub fn add_slice(&mut self, value: &[T]) -> &mut [T]

Appends a copy of value and returns the appended range.

Trait Implementations§

Source§

impl<T: Debug> Debug for ArrayBuilder<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for ArrayBuilder<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Index<usize> for ArrayBuilder<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for ArrayBuilder<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ArrayBuilder<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for ArrayBuilder<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for ArrayBuilder<T>
where Vec<T>: Send,

§

impl<T> Sync for ArrayBuilder<T>
where Vec<T>: Sync,

§

impl<T> Unpin for ArrayBuilder<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for ArrayBuilder<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for ArrayBuilder<T>
where Vec<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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.