# ArrayBuilder

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-arraybuilder/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ArrayBuilder<T>
```

A simple growable buffer.

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L9)

## Members

- [`new`](#function-new)
- [`length`](#function-length)
- [`capacity`](#function-capacity)
- [`add_item`](#function-add_item)
- [`clear`](#function-clear)
- [`reset`](#function-reset)
- [`as_span`](#function-as_span)
- [`as_span_mut`](#function-as_span_mut)
- [`as_slice`](#function-as_slice)
- [`as_slice_to`](#function-as_slice_to)
- [`as_slice_mut`](#function-as_slice_mut)
- [`set_length`](#function-set_length)
- [`add`](#function-add)
- [`add_slice`](#function-add_slice)

<a id="function-new"></a>

### new

```rust
const fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L14)

<a id="function-length"></a>

### length

```rust
fn length(self: &Self) -> usize
```

The number of items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L20)

<a id="function-capacity"></a>

### capacity

```rust
fn capacity(self: &Self) -> usize
```

The allocated capacity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L26)

<a id="function-add_item"></a>

### add_item

```rust
fn add_item(self: &mut Self, value: T)
```

Appends one item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L32)

<a id="function-clear"></a>

### clear

```rust
fn clear(self: &mut Self)
```

Removes every item, keeping the storage.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L38)

<a id="function-reset"></a>

### reset

```rust
fn reset(self: &mut Self)
```

Drops the storage (C# `arrayBuilder = default`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L43)

<a id="function-as_span"></a>

### as_span

```rust
fn as_span(self: &Self) -> &[T]
```

The items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L49)

<a id="function-as_span_mut"></a>

### as_span_mut

```rust
fn as_span_mut(self: &mut Self) -> &mut [T]
```

The items, mutably.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L55)

<a id="function-as_slice"></a>

### as_slice

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

`length` items starting at `start`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L61)

<a id="function-as_slice_to"></a>

### as_slice_to

```rust
fn as_slice_to(self: &Self, length: usize) -> &[T]
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L68)

<a id="function-as_slice_mut"></a>

### as_slice_mut

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

`length` items starting at `start`, mutably.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L74)

<a id="function-set_length"></a>

### set_length

```rust
fn set_length(self: &mut Self, value: usize)
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L81)

<a id="function-add"></a>

### add

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

Appends `length` default items and returns them.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L86)

<a id="function-add_slice"></a>

### add_slice

```rust
fn add_slice(self: &mut Self, value: &[T]) -> &mut [T]
```

Appends a copy of `value` and returns the appended range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/array_builder.rs#L93)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Debug`
- `Default`
- `Index<usize>`
- `IndexMut<usize>`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
