diff options
Diffstat (limited to 'askama_shared/src/generator.rs')
-rw-r--r-- | askama_shared/src/generator.rs | 13 |
1 files changed, 10 insertions, 3 deletions
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(()) } |