# RefCountDisposable

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

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

```rust
struct RefCountDisposable
```

A disposable that disposes its underlying disposable once it has been disposed itself and all
the dependent disposables it handed out have been disposed (`RefCountDisposable`).

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

## Members

- [`new`](#function-new)
- [`with_throw_when_disposed`](#function-with_throw_when_disposed)
- [`get_disposable`](#function-get_disposable)

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

### new

```rust
fn new(disposable: Rc<dyn IDisposable>) -> Rc<Self>
```

Counts the references to `disposable`.

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

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

### with_throw_when_disposed

```rust
fn with_throw_when_disposed(disposable: Rc<dyn IDisposable>, throw_when_disposed: bool) -> Rc<Self>
```

As `new`; with `throw_when_disposed`, asking a disposed instance for a
dependent disposable panics (upstream throws `ObjectDisposedException`) instead of returning
an empty one.

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

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

### get_disposable

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

A dependent disposable, which keeps the underlying disposable alive until it is disposed
(`GetDisposable`).

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)
- [`ICancelable`](/docs/0.5.0/api/ferroui-reactive/disposables/trait-icancelable/)

## Availability

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