ArrayBuilder
struct · ferroui-base · v0.5.0
struct ArrayBuilder<T>
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.
Members
newlengthcapacityadd_itemclearresetas_spanas_span_mutas_sliceas_slice_toas_slice_mutset_lengthaddadd_slice
new
const fn new() -> Self
length
fn length(self: &Self) -> usize
The number of items.
capacity
fn capacity(self: &Self) -> usize
The allocated capacity.
add_item
fn add_item(self: &mut Self, value: T)
Appends one item.
clear
fn clear(self: &mut Self)
Removes every item, keeping the storage.
reset
fn reset(self: &mut Self)
Drops the storage (C# arrayBuilder = default).
as_span
fn as_span(self: &Self) -> &[T]
The items.
as_span_mut
fn as_span_mut(self: &mut Self) -> &mut [T]
The items, mutably.
as_slice
fn as_slice(self: &Self, start: usize, length: usize) -> &[T]
length items starting at start.
as_slice_to
fn as_slice_to(self: &Self, length: usize) -> &[T]
The first length items (the original's AsSlice(length); its
AsSlice() is as_span).
as_slice_mut
fn as_slice_mut(self: &mut Self, start: usize, length: usize) -> &mut [T]
length items starting at start, mutably.
set_length
fn set_length(self: &mut Self, value: usize)
Sets the number of items; new items are default values.
add
fn add(self: &mut Self, length: usize) -> &mut [T]
Appends length default items and returns them.
add_slice
fn add_slice(self: &mut Self, value: &[T]) -> &mut [T]
Appends a copy of value and returns the appended range.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherDebugDefaultIndex<usize>IndexMut<usize>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.