Change the execution order of chain
and race
guards. #614
This commit is contained in:
parent
923ed490de
commit
4740579ec9
|
@ -225,7 +225,7 @@ pub fn generate_guards(
|
|||
guards = guard;
|
||||
} else {
|
||||
guards =
|
||||
Some(quote! { #crate_name::guard::GuardExt::and(#guard, #guards) });
|
||||
Some(quote! { #crate_name::guard::GuardExt::and(#guards, #guard) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ pub fn generate_guards(
|
|||
guards = guard;
|
||||
} else {
|
||||
guards =
|
||||
Some(quote! { #crate_name::guard::GuardExt::or(#guard, #guards) });
|
||||
Some(quote! { #crate_name::guard::GuardExt::or(#guards, #guard) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,9 @@ pub struct Or<A: Guard, B: Guard>(A, B);
|
|||
#[async_trait::async_trait]
|
||||
impl<A: Guard + Send + Sync, B: Guard + Send + Sync> Guard for Or<A, B> {
|
||||
async fn check(&self, ctx: &Context<'_>) -> Result<()> {
|
||||
let second_result = self.1.check(ctx).await;
|
||||
self.0.check(ctx).await.or(second_result)
|
||||
if self.0.check(ctx).await.is_ok() {
|
||||
return Ok(());
|
||||
}
|
||||
self.1.check(ctx).await
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user