# ReadOnlyObservableCollection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/binding/struct-readonlyobservablecollection/

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

```rust
struct ReadOnlyObservableCollection<T>
```

A read-only view of an observable collection (`ReadOnlyObservableCollection<T>`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L18)

## Members

- [`new`](#function-new)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)
- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`get`](#function-get)
- [`items`](#function-items)
- [`to_vec`](#function-to_vec)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)

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

### new

```rust
fn new(collection: ObservableCollection<T>) -> Self
```

The view of `collection` (`ReadOnlyObservableCollection(ObservableCollection<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L43)

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

### add_collection_changed

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

Adds a handler of the typed change notifications; returns the token that removes it
(`CollectionChanged +=`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L54)

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

### remove_collection_changed

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

Removes a handler (`CollectionChanged -=`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L59)

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

### count

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

The number of items (`Count`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L64)

<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.DynamicData/binding/read_only_observable_collection.rs#L68)

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

### get

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

The item at `index` (the indexer).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L73)

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

### items

```rust
fn items(self: &Self) -> Ref<'_, Vec<T>>
```

The items, borrowed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L78)

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

### to_vec

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

A copy of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L83)

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

### contains

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

Whether the collection has `item` (`Contains`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L88)

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

### index_of

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

The index of `item` (`IndexOf`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/read_only_observable_collection.rs#L93)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`ObservableCollectionEx<T>`](/docs/0.5.0/api/ferroui-dynamic-data/binding/trait-observablecollectionex/)
- `Clone`
- `PartialEq`
- `Debug`
- `From<ObservableCollection<T>>`
- `From<&ObservableCollectionExtended<T>>`
- [`INotifyCollectionChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifycollectionchanged/)
- [`INotifyPropertyChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifypropertychanged/)

## Availability

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