futures-rs
futures-rs copied to clipboard
Should `futures::future::abortable` be in `futures::future::FutureExt`?
Almost all functions in futures::future are future combinators, abortable looks like FutureExt::remote_handle, maybe it belongs to futures::future::FutureExt?
This was discussed in the PR that added abortable: https://github.com/rust-lang/futures-rs/pull/1079#discussion_r201834063
Personal preference but I think this makes more sense as a free function-- you wouldn't chain it like normal combinators since it doesn't return a
Future.
What about FutureExt::remote_handle? Like abortable, it also returns a tuple. To compare:
pub fn abortable<Fut>(future: Fut) -> (Abortable<Fut>, AbortHandle)
vs
pub fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
If remote_handle were implemented as a trait method, it could be like:
pub fn abortable(self) -> (Abortable<Self>, AbortHandle)
I asked this because personally I think functions in FutureExt are easier to discover. It took me some time to find that the abortable function exists.