From 1ebd13e912993b4c6ea5028f74d8aca87b44565e Mon Sep 17 00:00:00 2001 From: projectmoon Date: Wed, 26 May 2021 21:12:21 +0000 Subject: [PATCH] Change execution_allowed to a match for shorter reading. --- src/commands/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 937f7ff..8553791 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -109,14 +109,10 @@ pub trait Command: Send + Sync { /// ever. Later, we can add stuff like admin/regular user power /// separation, etc. fn execution_allowed(cmd: &(impl Command + ?Sized), ctx: &Context<'_>) -> Result<(), CommandError> { - if cmd.is_secure() { - if ctx.is_secure() { - Ok(()) - } else { - Err(CommandError::InsecureExecution) - } - } else { - Ok(()) + match cmd { + cmd if cmd.is_secure() && ctx.is_secure() => Ok(()), + cmd if cmd.is_secure() && !ctx.is_secure() => Err(CommandError::InsecureExecution), + _ => Ok(()), } }