5

Github Abortable streams by ibraheemdev · Pull Request #2410 · rust-lang/futures...

 2 years ago
source link: https://github.com/rust-lang/futures-rs/pull/2410
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Member

taiki-e left a comment

Thanks! This looks good to me!

Is there a better place to put Abortable than futures-util/src/abortable.rs? Maybe a shared/ folder?

shared/ is confusing with future/shared, so I think futures-util/src/abortable.rs is fine.

futures-util/src/abortable.rs

Outdated

Show resolved

/// # use futures::stream::{self, StreamExt};

///

/// let (abort_handle, abort_registration) = AbortHandle::new_pair();

/// let mut stream = Abortable::stream(stream::iter(vec![1, 2, 3]), abort_registration);

taiki-e on May 6

Member

This function doesn't seem to exist, but I think it's not actually a bad idea to have both Abortable::new (require T: Future) and Abortable::stream (require T: Stream) because we can prevent the creation of Abortables that cannot be polled. -- However, it may feel redundant when we provide other abortables (e.g., abortable sink) in the future.

ibraheemdev on May 6

Author

Contributor

At first I wrote Abortable::new and stream, but I thought that new for abortable futures specifically was a bit arbitrary.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK