-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how BoxFuture
s / BoxStream
s are often made
#2887
Conversation
@@ -9,6 +9,11 @@ pub use core::future::Future; | |||
|
|||
/// An owned dynamically typed [`Future`] for use in cases where you can't | |||
/// statically type your result or need to add some indirection. | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the wording and pattern in std, for example https://doc.rust-lang.org/std/iter/struct.Cloned.html
This struct is created by the cloned method on Iterator. See its documentation for more.
/// This type is often created by the [`boxed`] method on [`FutureExt`]. See its documentation for more. | ||
/// | ||
/// [`boxed`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html#method.boxed | ||
/// [`FutureExt`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this links back to docs.rs because futures-core does not depened on futures-util, where FutureExt
is defined
FYI @taiki-e |
Thanks! This seems reasonable to me. |
Could you add similar docs to other boxed types? |
Yes, I will do so |
BoxFuture
s are often madeBoxFuture
s / BoxStream
s are often made
Done |
Thank you again @taiki-e |
Rationale
Unless you are already familiar with the Rust futures ecosystem and
FuturesExt::boxed
it is not always obvious how to create aBoxFuture
Specifically, we have APIs for reading parquet files, which involve
BoxFuture
s that when a user clicks on the return type,The documentation doesn't lead them to
FutureExt::boxed
:Proposal
While a better improvement for our users is a full featured example (added in apache/arrow-rs#6505), I think this to propose improvements in this crate too to help the broader community
If the maintainers like this pattern, I am happy to add it for other similar types in Futures and Streams but I won't bother if you are not interested in this type of change