Crate stream_guard

Source
Expand description

A small RAII wrapper around a Stream that automatically invokes a user-defined action upon being dropped.

For example:

async fn f() {
    let mut s = stream::iter(0..3).guard(|| println!("Dropped!"));
    while let Some(i) = s.next().await {
        println!("{}", i);
    }
}

would print

0
1
2
Dropped!

Structs§

StreamGuard
A Stream wrapper that automatically runs a custom action when dropped.

Traits§

GuardStreamExt
A convenience extension for creating a StreamGuard via a method.