using<D extends Disposable> function

void using <D extends Disposable>(Disposable disposable, DisposableBlock<Disposable> block)

Use a Disposable and dispose of it right away.

Implementation

void using<D extends Disposable>(Disposable disposable, DisposableBlock block) {
  checkNotNull(disposable, message: () => "disposable can't be null");
  checkNotNull(block, message: () => "block can't be null");
  block(disposable);
  disposable.dispose();
}