# FerroList

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/collections/struct-ferrolist/

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

```rust
struct FerroList<T>
```

A notifying list.

Enumeration works on a snapshot, so the list may be modified from within
an enumeration or a change notification. The snapshot shares storage with
the list and is only copied if the list is modified while it is alive.

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L31)

## Members

- [`ptr_eq`](#function-ptr_eq)
- [`new`](#function-new)
- [`from_items`](#function-from_items)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)
- [`has_collection_changed_subscribers`](#function-has_collection_changed_subscribers)
- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`capacity`](#function-capacity)
- [`set_capacity`](#function-set_capacity)
- [`reset_behavior`](#function-reset_behavior)
- [`set_reset_behavior`](#function-set_reset_behavior)
- [`validate`](#function-validate)
- [`set_validate`](#function-set_validate)
- [`validator`](#function-validator)
- [`set_validator`](#function-set_validator)
- [`get`](#function-get)
- [`try_get`](#function-try_get)
- [`set`](#function-set)
- [`snapshot`](#function-snapshot)
- [`to_vec`](#function-to_vec)
- [`for_each`](#function-for_each)
- [`add`](#function-add)
- [`add_range`](#function-add_range)
- [`insert`](#function-insert)
- [`insert_range`](#function-insert_range)
- [`move_item`](#function-move_item)
- [`move_range`](#function-move_range)
- [`remove_at`](#function-remove_at)
- [`remove_range`](#function-remove_range)
- [`clear`](#function-clear)
- [`copy_to`](#function-copy_to)
- [`get_range`](#function-get_range)
- [`ensure_capacity`](#function-ensure_capacity)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`remove`](#function-remove)
- [`remove_all`](#function-remove_all)

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

### ptr_eq

```rust
fn ptr_eq(self: &Self, other: &Self) -> bool
```

Whether two handles refer to the same list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L116)

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

### new

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

Creates an empty list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L135)

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

### from_items

```rust
fn from_items(items: impl IntoIterator<Item = T>) -> Self
```

Creates a list with initial items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L147)

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

### add_collection_changed

```rust
fn add_collection_changed(self: &Self, handler: Rc<CollectionChangedHandler<T>>) -> u64
```

Subscribes to changes. Returns a token for
`remove_collection_changed`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L155)

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

### remove_collection_changed

```rust
fn remove_collection_changed(self: &Self, token: u64) -> bool
```

Unsubscribes a handler.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L160)

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

### has_collection_changed_subscribers

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

Whether anything is subscribed to changes, typed or untyped.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L165)

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

### count

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

The number of items in the list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L171)

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

### is_empty

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L176)

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

### capacity

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

The number of items the list can hold before its storage grows.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L181)

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

### set_capacity

```rust
fn set_capacity(self: &Self, capacity: usize)
```

Sets the number of items the list can hold before its storage grows.
## Panics
Panics if `capacity` is less than the number of items, as the
managed original throws.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L190)

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

### reset_behavior

```rust
fn reset_behavior(self: &Self) -> ResetBehavior
```

The reset behavior of the list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L203)

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

### set_reset_behavior

```rust
fn set_reset_behavior(self: &Self, value: ResetBehavior)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L207)

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

### validate

```rust
fn validate(self: &Self) -> Option<Rc<dyn Fn(&T) -> ()>>
where T: 'static
```

The validation routine that is invoked for every item before it is
added to the list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L213)

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

### set_validate

```rust
fn set_validate(self: &Self, value: Option<Rc<dyn Fn(&T) -> ()>>)
where T: 'static
```

Sets a validation routine that is invoked for every item before it is
added to the list; it rejects an item by panicking.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L229)

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

### validator

```rust
fn validator(self: &Self) -> Option<Rc<dyn IFerroListItemValidator<T>>>
where T: 'static
```

The validator that is invoked for every item before it is added to the
list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L249)

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

### set_validator

```rust
fn set_validator(self: &Self, value: Option<Rc<dyn IFerroListItemValidator<T>>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L259)

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

### get

```rust
fn get(self: &Self, index: usize) -> T
```

The item at `index`. Panics if out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L265)

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

### try_get

```rust
fn try_get(self: &Self, index: usize) -> Option<T>
```

The item at `index`, if in range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L271)

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

### set

```rust
fn set(self: &Self, index: usize, value: T)
where T: PartialEq
```

Replaces the item at `index`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L276)

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

### snapshot

```rust
fn snapshot(self: &Self) -> Rc<Vec<T>>
```

A snapshot of the items. It stays valid and unchanged if the list is
modified.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L297)

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

### to_vec

```rust
fn to_vec(self: &Self) -> Vec<T>
```

Copies the items into a vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L309)

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

### for_each

```rust
fn for_each(self: &Self, f: impl FnMut(&T) -> ())
```

Calls `f` for each item of a snapshot of the list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L314)

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

### add

```rust
fn add(self: &Self, item: T)
```

Adds an item to the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L324)

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

### add_range

```rust
fn add_range(self: &Self, items: impl IntoIterator<Item = T>)
```

Adds multiple items to the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L332)

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

### insert

```rust
fn insert(self: &Self, index: usize, item: T)
```

Inserts an item at the specified index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L337)

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

### insert_range

```rust
fn insert_range(self: &Self, index: usize, items: impl IntoIterator<Item = T>)
```

Inserts multiple items at the specified index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L344)

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

### move_item

```rust
fn move_item(self: &Self, old_index: usize, new_index: usize)
```

Moves an item to a new index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L359)

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

### move_range

```rust
fn move_range(self: &Self, old_index: usize, count: usize, new_index: usize)
```

Moves multiple items to a new index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L375)

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

### remove_at

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

Removes the item at the specified index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L396)

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

### remove_range

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

Removes a range of elements from the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L405)

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

### clear

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

Removes all items from the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L417)

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

### copy_to

```rust
fn copy_to(self: &Self, array: &mut [T], array_index: usize)
```

Copies the items into `array`, starting at `array_index`.
## Panics
Panics if `array` is too small, as the managed original throws.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L462)

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

### get_range

```rust
fn get_range(self: &Self, index: usize, count: usize) -> Vec<T>
```

Gets a range of items from the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L472)

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

### ensure_capacity

```rust
fn ensure_capacity(self: &Self, capacity: usize)
```

Ensures that the capacity of the list is at least `capacity`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L477)

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

### contains

```rust
fn contains(self: &Self, item: &T) -> bool
```

Tests whether the collection contains an item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L583)

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

### index_of

```rust
fn index_of(self: &Self, item: &T) -> Option<usize>
```

The index of an item in the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L588)

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

### remove

```rust
fn remove(self: &Self, item: &T) -> bool
```

Removes an item from the collection. Returns true if it was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L593)

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

### remove_all

```rust
fn remove_all(self: &Self, items: impl IntoIterator<Item = T>)
```

Removes multiple items from the collection.

Each run of adjacent items that are removed is notified as one
removal, from the end of the list to its start.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/collections/ferro_list.rs#L626)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`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/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- [`WeakEventSender`](/docs/0.5.0/api/ferroui-base/utilities/trait-weakeventsender/)
- `Clone`
- `PartialEq`
- `Debug`
- `Default`
- [`INotifyCollectionChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifycollectionchanged/)
- [`INotifyPropertyChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifypropertychanged/)
- [`IFerroList<T>`](/docs/0.5.0/api/ferroui-base/collections/trait-iferrolist/)
- [`IFerroReadOnlyList<T>`](/docs/0.5.0/api/ferroui-base/collections/trait-iferroreadonlylist/)
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)

## Availability

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