diff options
author | bott <mhpoin@gmail.com> | 2018-09-21 02:09:59 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-09-21 13:42:56 +0200 |
commit | 94bb47a78d32c5a5162ce5475b8a4c310940fef2 (patch) | |
tree | 2a221067faf5b32e060582a5522ef3b2bd5c17ad /askama_derive/src | |
parent | ba91884d762bcf0b4a5bd9ca18d14be240570316 (diff) | |
download | askama-94bb47a78d32c5a5162ce5475b8a4c310940fef2.tar.gz askama-94bb47a78d32c5a5162ce5475b8a4c310940fef2.tar.bz2 askama-94bb47a78d32c5a5162ce5475b8a4c310940fef2.zip |
fix panicked on range-based for loop
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index b6b5146..2a233d5 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -404,7 +404,10 @@ impl<'a> Generator<'a> { self.locals.insert(name); buf.write(name); } - buf.writeln(&format!(") in (&{}).into_iter().enumerate() {{", expr_code)); + match iter { + Expr::Range(_, _, _) => buf.writeln(&format!(") in ({}).enumerate() {{", expr_code)), + _ => buf.writeln(&format!(") in (&{}).into_iter().enumerate() {{", expr_code)), + }; self.handle(ctx, body, buf, AstLevel::Nested); self.handle_ws(buf, ws2); |