Suggest LocalBoxFuture specifically

This commit is contained in:
Matt Fellenz 2022-04-18 10:54:01 -07:00
parent e575d35da2
commit cf71b847e7
No known key found for this signature in database
GPG Key ID: D0061A7BB596E3B3
1 changed files with 7 additions and 3 deletions

View File

@ -68,9 +68,13 @@ pub trait FromRequest: Sized {
/// Future that resolves to a Self.
///
/// To refer to the type of an async function or block here, you have two options.
/// The first is to use a boxed future such as `futures::future::BoxFuture`. This works on stable and nightly.
/// The second is to use `impl Future`, which requires `#![feature(type_alias_impl_trait)]` so only works on nightly.
/// To use an async function or block here, you can a boxed future such as `futures::future::LocalBoxFuture`.
/// This is an alias for a pinned Box, so you can create it with the following syntax:
/// ```
/// Box::pin(async {
/// ...
/// })
/// ```
type Future: Future<Output = Result<Self, Self::Error>>;
/// Create a Self from request parts asynchronously.