This commit is contained in:
Aurelien Foucault 2020-10-03 23:52:23 +02:00
parent 549aa7cc72
commit 92716a2186
2 changed files with 6 additions and 4 deletions

View File

@ -136,9 +136,9 @@ pub fn generate_guards(
.into());
}
if let NestedMeta::Meta(rule) = &args.nested[0] {
return generate_guards(crate_name, rule);
generate_guards(crate_name, rule)
} else {
return Err(Error::new_spanned(&args.nested[0], "Invalid rule.").into());
Err(Error::new_spanned(&args.nested[0], "Invalid rule.").into())
}
}
"and" => {

View File

@ -35,7 +35,8 @@ pub struct And<A: Guard, B: Guard>(A, B);
#[async_trait::async_trait]
impl<A: Guard + Send + Sync, B: Guard + Send + Sync> Guard for And<A, B> {
async fn check(&self, ctx: &Context<'_>) -> Result<()> {
self.0.check(ctx).await.and(self.1.check(ctx).await)
let second_result = self.1.check(ctx).await;
self.0.check(ctx).await.and(second_result)
}
}
@ -45,7 +46,8 @@ 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<()> {
self.0.check(ctx).await.or(self.1.check(ctx).await)
let second_result = self.1.check(ctx).await;
self.0.check(ctx).await.or(second_result)
}
}