diff options
author | vallentin <mail@vallentin.dev> | 2021-01-02 23:02:59 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-01-05 16:17:14 +0100 |
commit | b76f7ef778dd37db08cb4dba2dc9329b15bbe984 (patch) | |
tree | f12a3086ce2b5d5af9ed4ff6274c1fd44b3c2e1c /askama_shared/src/generator.rs | |
parent | c2102d4d1f33fda499bccb09f77ea9cbd72f2018 (diff) | |
download | askama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.tar.gz askama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.tar.bz2 askama-b76f7ef778dd37db08cb4dba2dc9329b15bbe984.zip |
Removed implicit borrowing of literals, calls, and more (fixes #404)
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(()) } |