Skip to content

Commit

Permalink
Removes unnecessary fn main from DropStreamExt docs and increments ve…
Browse files Browse the repository at this point in the history
…rsion number.
  • Loading branch information
lukasfri committed May 26, 2024
1 parent 1f2015e commit 29ce9af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "drop-stream"
version = "0.3.0"
version = "0.3.1"
authors = ["Lukas Friman <[email protected]>"]
description = "A stream that wraps another stream with a closure that is called once it is dropped."
documentation = "https://docs.rs/drop-stream"
Expand All @@ -11,7 +11,7 @@ repository = "https://github.com/DreamplaySE/drop-stream"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
futures-core = "0.3"
futures-core = "0.3"

[dev-dependencies]
futures = "0.3"
futures = "0.3"
24 changes: 11 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,21 @@ pub trait DropStreamExt<U: FnOnce() + Unpin>: Stream + Unpin + Sized {
/// use futures::{stream::repeat, Stream};
/// use drop_stream::DropStreamExt;
///
/// fn main() {
/// let some_stream = repeat(true);
/// let some_stream = repeat(true);
///
/// let mut has_run = false;
/// let has_run_ref = &mut has_run;
/// let drop_stream = some_stream.on_drop(move || {
/// *has_run_ref = true;
/// println!("Stream has been dropped!")
/// });
/// let mut has_run = false;
/// let has_run_ref = &mut has_run;
/// let drop_stream = some_stream.on_drop(move || {
/// *has_run_ref = true;
/// println!("Stream has been dropped!")
/// });
///
/// let mut drop_stream = Box::pin(drop_stream);
/// let mut drop_stream = Box::pin(drop_stream);
///
/// // Some stream work and polling...
/// // Some stream work and polling...
///
/// drop(drop_stream); // Runs the closure
/// assert!(has_run);
/// }
/// drop(drop_stream); // Runs the closure
/// assert!(has_run);
/// ```
fn on_drop(self, dropper: U) -> DropStream<Self, Self::Item, U>;
}
Expand Down

0 comments on commit 29ce9af

Please sign in to comment.