# TextRangeCollection

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

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

```rust
struct TextRangeCollection
```

An observable shared collection of copied highlight values.

Unlike a live document range, an item does not follow edits. Applications
replace range values when their search results or annotations change.

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

## Members

- [`new`](#function-new)
- [`from_items`](#function-from_items)
- [`count`](#function-count)
- [`len`](#function-len)
- [`is_empty`](#function-is_empty)
- [`capacity`](#function-capacity)
- [`clear`](#function-clear)
- [`add`](#function-add)
- [`add_range`](#function-add_range)
- [`add_span`](#function-add_span)
- [`insert`](#function-insert)
- [`insert_range`](#function-insert_range)
- [`get`](#function-get)
- [`set`](#function-set)
- [`remove_at`](#function-remove_at)
- [`remove`](#function-remove)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`snapshot`](#function-snapshot)
- [`to_vec`](#function-to_vec)
- [`iter`](#function-iter)
- [`for_each`](#function-for_each)
- [`collection_changed`](#function-collection_changed)

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

### new

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L171)

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

### from_items

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L174)

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

### count

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L177)

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

### len

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L180)

<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.Controls/documents/text_highlight_range.rs#L183)

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

### capacity

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L186)

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

### clear

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L189)

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

### add

```rust
fn add(self: &Self, range: TextHighlightRange)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L192)

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

### add_range

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L195)

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

### add_span

```rust
fn add_span(self: &Self, range: Range<usize>) -> Result<(), TextHighlightError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L198)

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

### insert

```rust
fn insert(self: &Self, index: usize, range: TextHighlightRange)
```

Like the source collection, inserting past the end appends.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L204)

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

### insert_range

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L207)

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

### get

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L210)

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

### set

```rust
fn set(self: &Self, index: usize, range: TextHighlightRange) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L213)

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

### remove_at

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L220)

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

### remove

```rust
fn remove(self: &Self, range: &TextHighlightRange) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L225)

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

### contains

```rust
fn contains(self: &Self, range: &TextHighlightRange) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L228)

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

### index_of

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L231)

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

### snapshot

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

Copies every value so setters on a returned item cannot mutate the list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L236)

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

### to_vec

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L239)

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

### iter

```rust
fn iter(self: &Self) -> std::vec::IntoIter<TextHighlightRange>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L242)

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

### for_each

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L245)

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

### collection_changed

```rust
fn collection_changed(self: &Self, handler: impl Fn(&'a NotifyCollectionChangedEventArgs<'b, TextHighlightRange>) -> () + 'static) -> Subscription
```

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/text_highlight_range.rs#L253)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `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`
- `Clone`
- `Default`
- `PartialEq`
- `Debug`
- [`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/).
