# ItemCollection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-itemcollection/

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

```rust
struct ItemCollection
```

Holds the list of items that constitute the content of an
`ItemsControl`.

The value is a shared handle: clones refer to the same collection, and
handles compare by identity.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L24)

## Members

- [`view`](#function-view)
- [`set`](#function-set)
- [`is_read_only`](#function-is_read_only)
- [`add`](#function-add)
- [`clear`](#function-clear)
- [`insert`](#function-insert)
- [`remove_at`](#function-remove_at)
- [`remove`](#function-remove)

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

### view

```rust
fn view(self: &Self) -> &Rc<ItemsSourceView>
```

The read-only view of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L65)

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

### set

```rust
fn set(self: &Self, index: usize, value: Option<BoxedValue>)
```

Replaces the item at the specified index.

Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L72)

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

### is_read_only

```rust
fn is_read_only(self: &Self) -> bool
```

Whether the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L77)

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

### add

```rust
fn add(self: &Self, value: Option<BoxedValue>) -> i32
```

Adds an item to the items control.

Returns the position into which the new element was inserted.
Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L90)

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

### clear

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

Clears the collection and releases the references on all items
currently in the collection.

Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L100)

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

### insert

```rust
fn insert(self: &Self, index: usize, value: Option<BoxedValue>)
```

Inserts an element into the collection at the specified index.

Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L107)

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

### remove_at

```rust
fn remove_at(self: &Self, index: usize)
```

Removes the item at the specified index of the collection or view.

Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L114)

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

### remove

```rust
fn remove(self: &Self, value: &Option<BoxedValue>) -> bool
```

Removes the specified item reference from the collection or view.
Returns true if the item was removed.

Panics if the collection is in items source mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/item_collection.rs#L122)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)
- `Clone`
- `PartialEq`
- `Debug`
- `Deref`

## Availability

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