From 94bb47a78d32c5a5162ce5475b8a4c310940fef2 Mon Sep 17 00:00:00 2001 From: bott Date: Fri, 21 Sep 2018 02:09:59 +0200 Subject: fix panicked on range-based for loop --- askama_derive/src/generator.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'askama_derive') 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); -- cgit