From 84fe3814033d1ec8669f253964cfa1145b4f53e9 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Mon, 31 Jan 2022 11:34:48 +0100 Subject: Remove `panic!()` in `loop.cycle([])` --- askama_shared/src/generator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'askama_shared/src/generator.rs') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index acd716b..daf22ae 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1328,7 +1328,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { "cycle" => match args { [arg] => { if matches!(arg, Expr::Array(arr) if arr.is_empty()) { - panic!("loop.cycle(…) cannot use an empty array."); + return Err("loop.cycle(…) cannot use an empty array".into()); } buf.write("({"); buf.write("let _cycle = &("); -- cgit