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;
|
guards = guard;
|
||||||
} else {
|
} else {
|
||||||
guards =
|
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;
|
guards = guard;
|
||||||
} else {
|
} else {
|
||||||
guards =
|
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]
|
#[async_trait::async_trait]
|
||||||
impl<A: Guard + Send + Sync, B: Guard + Send + Sync> Guard for Or<A, B> {
|
impl<A: Guard + Send + Sync, B: Guard + Send + Sync> Guard for Or<A, B> {
|
||||||
async fn check(&self, ctx: &Context<'_>) -> Result<()> {
|
async fn check(&self, ctx: &Context<'_>) -> Result<()> {
|
||||||
let second_result = self.1.check(ctx).await;
|
if self.0.check(ctx).await.is_ok() {
|
||||||
self.0.check(ctx).await.or(second_result)
|
return Ok(());
|
||||||
|
}
|
||||||
|
self.1.check(ctx).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user