# AsDisposable

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

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

```rust
trait AsDisposable
```

An item that may be a disposable (`item as IDisposable`): `DisposeMany` disposes the items for
which `to_disposable` gives a disposable, and leaves the others
alone, as upstream disposes the items that implement `IDisposable`.

Deviation (DEVIATIONS.md, DynamicData): .NET tests the type of an item at run time; Rust has no
such test for a generic item, so the type of the items says whether they are disposable. Every
`Rc` of a disposable is one (`Rc<dyn IDisposable>` and `Rc<X>` for `X: IDisposable`); another
type implements the trait, or `dispose_many_with` takes the function that disposes an item.

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

## Members

- [`to_disposable`](#function-to_disposable)

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

### to_disposable

```rust
fn to_disposable(self: &Self) -> Option<Rc<dyn IDisposable>>
```

The item as a disposable, or `None` when it is not one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/as_disposable.rs#L17)

## Trait implementations

- [`AsDisposable`](/docs/0.5.0/api/ferroui-dynamic-data/trait-asdisposable/)

## Availability

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