Skip to main content

AsDisposable

Trait AsDisposable 

Source
pub trait AsDisposable {
    // Required method
    fn to_disposable(&self) -> Option<Rc<dyn IDisposable>>;
}
Expand description

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.

Required Methods§

Source

fn to_disposable(&self) -> Option<Rc<dyn IDisposable>>

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsDisposable for Rc<dyn IDisposable>

Source§

impl<X: AsDisposable> AsDisposable for Option<X>

Source§

impl<X: IDisposable + 'static> AsDisposable for Rc<X>

Implementors§