1 stable release
1.0.0 | May 31, 2024 |
---|
#787 in Asynchronous
30 downloads per month
Used in 5 crates
(via lighthouse-client)
6KB
Stream Guard
A small RAII wrapper around a Stream
(asynchronous iterator) that automatically invokes a user-defined action upon being dropped.
lib.rs
:
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!
Dependencies
~1–1.6MB
~32K SLoC