aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2022-02-03 16:09:26 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2022-02-03 18:09:55 +0100
commit509d23a6c5e8637d0d060db286fad43c91c0fe38 (patch)
treefd277a2b176cc69a2cdef7a9ad1b7a9a7ed4f889
parent2d457f54f50de8a9430f1e6e3da42244957911d1 (diff)
downloadaskama-509d23a6c5e8637d0d060db286fad43c91c0fe38.tar.gz
askama-509d23a6c5e8637d0d060db286fad43c91c0fe38.tar.bz2
askama-509d23a6c5e8637d0d060db286fad43c91c0fe38.zip
Replace if-let with match
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs10
1 files 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();