This commit is contained in:
Rob Ede 2022-01-12 15:04:02 +00:00
parent c0a09f0ebd
commit 0ee42c2346
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
1 changed files with 11 additions and 21 deletions

View File

@ -11,17 +11,15 @@ use crate::{
///
/// # What Is A Request Handler
/// A request handler has three requirements:
/// 1. It is an async function (or a function/closure that returns an appropriate future)
/// and has no more than 12 paramters;
/// 2. The function parameters implement [`FromRequest`];
/// 3. The async function (or future) resolves to a type that can be converted into an
/// 1. It is an async function (or a function/closure that returns an appropriate future);
/// 1. The function parameters (up to 12) implement [`FromRequest`];
/// 1. The async function (or future) resolves to a type that can be converted into an
/// [`HttpResponse`] (i.e., it implements the [`Responder`] trait).
///
/// # Compiler Errors
/// If you get the error `the trait Handler<_> is not implemented`, then your handler does not
/// fulfill the _first_ of the above requirements.
/// Missing other requirements manifest as errors on implementing [`FromRequest`] and [`Responder`]
/// , respectively.
/// fulfill the _first_ of the above requirements. Missing other requirements manifest as errors on
/// implementing [`FromRequest`] and [`Responder`], respectively.
///
/// # How Do Handlers Receive Variable Numbers Of Arguments
/// Rest assured there is no macro magic here; it's just traits.
@ -156,21 +154,13 @@ mod tests {
#[test]
fn arg_number() {
async fn handler_min() {}
#[rustfmt::skip]
#[allow(clippy::too_many_arguments, clippy::just_underscores_and_digits)]
async fn handler_max(
_01: (),
_02: (),
_03: (),
_04: (),
_05: (),
_06: (),
_07: (),
_08: (),
_09: (),
_10: (),
_11: (),
_12: (),
) {
}
_01: (), _02: (), _03: (), _04: (), _05: (), _06: (),
_07: (), _08: (), _09: (), _10: (), _11: (), _12: (),
) {}
assert_impl_handler(handler_min);
assert_impl_handler(handler_max);