From 509d23a6c5e8637d0d060db286fad43c91c0fe38 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 3 Feb 2022 16:09:26 +0100 Subject: Replace if-let with match --- askama_shared/src/generator.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 924d747..63a0154 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -665,8 +665,8 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { return self.write_block(buf, None, ws); } - let (def, own_ctx) = - if let Some(s) = scope { + let (def, own_ctx) = match scope { + Some(s) => { let path = ctx.imports.get(s).ok_or_else(|| { CompileError::from(format!("no import found for scope {:?}", s)) })?; @@ -677,13 +677,15 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { CompileError::from(format!("macro {:?} not found in scope {:?}", name, s)) })?; (def, mctx) - } else { + } + None => { let def = ctx .macros .get(name) .ok_or_else(|| CompileError::from(format!("macro {:?} not found", name)))?; (def, ctx) - }; + } + }; self.flush_ws(ws); // Cannot handle_ws() here: whitespace from macro definition comes first self.locals.push(); -- cgit