# AsAsyncDisposable

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

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

```rust
trait AsAsyncDisposable
```

An item that may be disposable, at once or by a task: `AsyncDisposeMany` disposes the items for
which `to_item_disposal` gives a disposal, and leaves the
others alone, as upstream disposes the items that implement `IDisposable` or
`IAsyncDisposable`.

Deviation (DEVIATIONS.md, DynamicData): .NET tests the type of an item at run time, and prefers
`IDisposable` when an item implements both. Rust has no such test for a generic item, so the
type of the items says how they are disposed: an `Rc` of an [`IAsyncDisposable`](/docs/0.5.0/api/ferroui-dynamic-data/trait-iasyncdisposable/) is disposed by
its task, an `Rc<dyn IDisposable>` at once. Another type implements the trait, or
`async_dispose_many_with` takes the function that tells how an item is disposed.

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

## Members

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

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

### to_item_disposal

```rust
fn to_item_disposal(self: &Self) -> Option<ItemDisposal>
```

How the item is disposed, or `None` when it is not disposable.

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

## Trait implementations

- [`AsAsyncDisposable`](/docs/0.5.0/api/ferroui-dynamic-data/trait-asasyncdisposable/)

## Availability

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