aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2021-01-02 23:02:59 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-01-05 16:17:14 +0100
commitb76f7ef778dd37db08cb4dba2dc9329b15bbe984 (patch)
treef12a3086ce2b5d5af9ed4ff6274c1fd44b3c2e1c /askama_shared/src/generator.rs
parentc2102d4d1f33fda499bccb09f77ea9cbd72f2018 (diff)
downloadaskama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.tar.gz
askama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.tar.bz2
askama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.zip
Removed implicit borrowing of literals, calls, and more (fixes #404)
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs13
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(())
}