# Disposable

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/disposables/struct-disposable/

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

```rust
struct Disposable
```

The factory of the common disposables (`Disposable`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/disposable.rs#L16)

## Members

- [`empty`](#function-empty)
- [`create`](#function-create)
- [`create_with_state`](#function-create_with_state)

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

### empty

```rust
fn empty() -> Rc<dyn IDisposable>
```

A disposable that does nothing when disposed (`Disposable.Empty`). The instance is shared by
the thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/disposable.rs#L27)

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

### create

```rust
fn create(dispose: impl FnOnce() -> () + 'static) -> Rc<dyn IDisposable>
```

A disposable that runs `dispose` the first time it is disposed (`Disposable.Create`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/disposable.rs#L35)

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

### create_with_state

```rust
fn create_with_state<S: 'static>(state: S, dispose: impl FnOnce(S) -> () + 'static) -> Rc<dyn IDisposable>
```

A disposable that runs `dispose` with `state` the first time it is disposed
(`Disposable.Create<TState>`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/disposable.rs#L41)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`

## Availability

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