From ae6cddf9073c9bb1e3850c55151cc83cf5e9948a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 28 Dec 2021 00:45:38 +0000 Subject: [PATCH] improve docs for any and all guards --- src/guard.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/guard.rs b/src/guard.rs index 58a6108f7..bc1deaf11 100644 --- a/src/guard.rs +++ b/src/guard.rs @@ -151,7 +151,7 @@ where } } -/// Return guard that matches if any of supplied guards. +/// Creates a guard that matches if any added guards match. /// /// # Examples /// The handler below will be called for either request method `GET` or `POST`. @@ -171,13 +171,15 @@ pub fn Any(guard: F) -> AnyGuard { } } -/// Matches any of supplied guards. +/// A collection of guards that match if the disjunction of their `check` outcomes is true. +/// +/// That is, only one contained guard needs to match in order for the aggregate guard to match. pub struct AnyGuard { guards: Vec>, } impl AnyGuard { - /// Add guard to a list of guards to check + /// Adds new guard to the collection of guards to check. pub fn or(mut self, guard: F) -> Self { self.guards.push(Box::new(guard)); self @@ -196,7 +198,7 @@ impl Guard for AnyGuard { } } -/// Creates a guard that matches if all of the supplied guards. +/// Creates a guard that matches if all added guards match. /// /// # Examples /// The handler below will only be called if the request method is `GET` **and** the specified @@ -218,13 +220,15 @@ pub fn All(guard: F) -> AllGuard { } } -/// Matches if all of supplied guards. +/// A collection of guards that match if the conjunction of their `check` outcomes is true. +/// +/// That is, **all** contained guard needs to match in order for the aggregate guard to match. pub struct AllGuard { guards: Vec>, } impl AllGuard { - /// Add new guard to the list of guards to check + /// Adds new guard to the collection of guards to check. pub fn and(mut self, guard: F) -> Self { self.guards.push(Box::new(guard)); self