diff options
author | max <gmx.sht@gmail.com> | 2023-12-13 15:34:54 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-12-13 16:47:02 +0100 |
commit | 3d52283b74573af509deb3c47cbabf7b7b58b1dd (patch) | |
tree | 3abd5a1a4f903dd305c83a7474a4bbb1f7598df9 /askama_derive/src | |
parent | 28182a1549a6546750d3f9834cb35686b89c3cf9 (diff) | |
download | askama-3d52283b74573af509deb3c47cbabf7b7b58b1dd.tar.gz askama-3d52283b74573af509deb3c47cbabf7b7b58b1dd.tar.bz2 askama-3d52283b74573af509deb3c47cbabf7b7b58b1dd.zip |
Add automatic borrowing to let statement
Signed-off-by: max <gmx.sht@gmail.com>
Diffstat (limited to 'askama_derive/src')
-rw-r--r-- | askama_derive/src/generator.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 6004aff..df15bdc 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -916,7 +916,14 @@ impl<'a> Generator<'a> { }; let mut expr_buf = Buffer::new(0); + let borrow_val = !is_copyable(val); + if borrow_val { + expr_buf.write("&("); + } self.visit_expr(&mut expr_buf, val)?; + if borrow_val { + expr_buf.write(")"); + } let shadowed = self.is_shadowing_variable(&l.var)?; if shadowed { |