Improve documentation for FromRequest::Future

This commit is contained in:
Matt Fellenz 2022-04-15 08:26:12 -07:00
parent de9e41484a
commit e575d35da2
No known key found for this signature in database
GPG Key ID: D0061A7BB596E3B3
1 changed files with 4 additions and 0 deletions

View File

@ -67,6 +67,10 @@ pub trait FromRequest: Sized {
type Error: Into<Error>;
/// 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.
type Future: Future<Output = Result<Self, Self::Error>>;
/// Create a Self from request parts asynchronously.