Skip to content
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 BoxFutures / BoxStreams are often made #2887

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions futures-core/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Copy link
Contributor Author

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.

Here is how it looks rendered:
Screenshot 2024-10-03 at 9 34 52 AM

/// 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
Copy link
Contributor Author

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

#[cfg(feature = "alloc")]
pub type BoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + Send + 'a>>;

Expand Down