From b76f7ef778dd37db08cb4dba2dc9329b15bbe984 Mon Sep 17 00:00:00 2001 From: vallentin Date: Sat, 2 Jan 2021 23:02:59 +0100 Subject: Removed implicit borrowing of literals, calls, and more (fixes #404) --- askama_shared/src/generator.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'askama_shared/src/generator.rs') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index cde0ead..801db37 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1275,9 +1275,12 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { for (i, arg) in args.iter().enumerate() { if i > 0 { - buf.write(", &"); - } else { - buf.write("&"); + buf.write(", "); + } + + let borrow = !arg.is_copyable(); + if borrow { + buf.write("&("); } let scoped = matches!(arg, @@ -1293,6 +1296,10 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { } else { self.visit_expr(buf, arg)?; } + + if borrow { + buf.write(")"); + } } Ok(()) } -- cgit