# OptionObservableExtensions

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/kernel/trait-optionobservableextensions/

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

```rust
trait OptionObservableExtensions<T: Clone + 'static>
```

The operators of sequences of options (`OptionObservableExtensions`), implemented for
`Rc<dyn IObservable<Option<T>>>`.

It also carries `EditDiff` of a sequence of options (`ObservableCacheEx.EditDiff(
IObservable<Optional<TObject>>, ..)`), as `edit_diff_optional`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L14)

## Members

- [`options`](#function-options)
- [`convert`](#function-convert)
- [`convert_optional`](#function-convert_optional)
- [`convert_or`](#function-convert_or)
- [`or_else`](#function-or_else)
- [`on_has_value`](#function-on_has_value)
- [`on_has_value_with_else`](#function-on_has_value_with_else)
- [`on_has_no_value`](#function-on_has_no_value)
- [`on_has_no_value_with_else`](#function-on_has_no_value_with_else)
- [`select_values`](#function-select_values)
- [`value_or`](#function-value_or)
- [`value_or_default`](#function-value_or_default)
- [`value_or_throw`](#function-value_or_throw)
- [`edit_diff_optional`](#function-edit_diff_optional)
- [`edit_diff_optional_with_comparer`](#function-edit_diff_optional_with_comparer)

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

### options

```rust
fn options(self: &Self) -> Rc<dyn IObservable<Option<T>>>
```

The sequence as the handle the operators take.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L16)

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

### convert

```rust
fn convert<U: 'static>(self: &Self, converter: impl Fn(T) -> U + 'static) -> Rc<dyn IObservable<Option<U>>>
```

Each value converted by `converter`; none stays none (`Convert(Func<TSource, TDestination>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L19)

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

### convert_optional

```rust
fn convert_optional<U: 'static>(self: &Self, converter: impl Fn(T) -> Option<U> + 'static) -> Rc<dyn IObservable<Option<U>>>
```

The option that `converter` makes of each value; none stays none
(`Convert(Func<TSource, Optional<TDestination>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L25)

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

### convert_or

```rust
fn convert_or<U: 'static>(self: &Self, converter: impl Fn(T) -> U + 'static, fallback_converter: impl Fn() -> U + 'static) -> Rc<dyn IObservable<U>>
```

Each value converted by `converter`, and what `fallback_converter` makes for none
(`ConvertOr`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L31)

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

### or_else

```rust
fn or_else(self: &Self, fallback_operation: impl Fn() -> Option<T> + 'static) -> Rc<dyn IObservable<Option<T>>>
```

The options, with what `fallback_operation` makes in place of none (`OrElse`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L39)

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

### on_has_value

```rust
fn on_has_value(self: &Self, action: impl Fn(&T) -> () + 'static) -> Rc<dyn IObservable<Option<T>>>
```

Runs `action` with each value (`OnHasValue(Action<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L47)

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

### on_has_value_with_else

```rust
fn on_has_value_with_else(self: &Self, action: impl Fn(&T) -> () + 'static, else_action: impl Fn() -> () + 'static) -> Rc<dyn IObservable<Option<T>>>
```

Runs `action` with each value, and `else_action` for each none
(`OnHasValue(Action<T>, Action)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L55)

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

### on_has_no_value

```rust
fn on_has_no_value(self: &Self, action: impl Fn() -> () + 'static) -> Rc<dyn IObservable<Option<T>>>
```

Runs `action` for each none (`OnHasNoValue(Action)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L62)

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

### on_has_no_value_with_else

```rust
fn on_has_no_value_with_else(self: &Self, action: impl Fn() -> () + 'static, else_action: impl Fn(&T) -> () + 'static) -> Rc<dyn IObservable<Option<T>>>
```

Runs `action` for each none, and `else_action` with each value
(`OnHasNoValue(Action, Action<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L70)

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

### select_values

```rust
fn select_values(self: &Self) -> Rc<dyn IObservable<T>>
```

The values; the nones are left out (`SelectValues`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L77)

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

### value_or

```rust
fn value_or(self: &Self, value_selector: impl Fn() -> T + 'static) -> Rc<dyn IObservable<T>>
```

The values, with what `value_selector` makes in place of none (`ValueOr`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L82)

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

### value_or_default

```rust
fn value_or_default(self: &Self) -> Rc<dyn IObservable<T>>
where T: Default
```

The values, with the default value of `T` in place of none (`ValueOrDefault`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L87)

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

### value_or_throw

```rust
fn value_or_throw(self: &Self, exception_generator: impl Fn() -> ObservableError + 'static) -> Rc<dyn IObservable<T>>
```

The values; a none ends the sequence with the error of `exception_generator`
(`ValueOrThrow`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L96)

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

### edit_diff_optional

```rust
fn edit_diff_optional<K: Eq + std::hash::Hash + Clone + 'static>(self: &Self, key_selector: impl Fn(&T) -> K + 'static) -> Rc<dyn IObservable<crate::cache::ChangeSet<T, K>>>
where T: PartialEq
```

The changes of a cache that holds the value of the option, keyed by `key_selector`: a
value adds it, another value with the same key updates it unless it is equal, one with
another key replaces it, and none removes it (`EditDiff(IObservable<Optional<TObject>>,
Func<TObject, TKey>)`, equality of `PartialEq`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L117)

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

### edit_diff_optional_with_comparer

```rust
fn edit_diff_optional_with_comparer<K: Eq + std::hash::Hash + Clone + 'static>(self: &Self, key_selector: impl Fn(&T) -> K + 'static, equality_comparer: impl Fn(&T, &T) -> bool + 'static) -> Rc<dyn IObservable<crate::cache::ChangeSet<T, K>>>
```

`edit_diff_optional` with the equality of `equality_comparer`
(`EditDiff(.., IEqualityComparer<TObject>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/kernel/option_observable_extensions.rs#L129)

## Trait implementations

- [`OptionObservableExtensions<T>`](/docs/0.5.0/api/ferroui-dynamic-data/kernel/trait-optionobservableextensions/)

## Availability

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