From 1ee067f2b62a994fe1200fba8898e8909acd0ce0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 3 Jan 2024 15:20:50 +0100 Subject: Revert "Add automatic borrowing to let statement" This reverts commit 3d52283b74573af509deb3c47cbabf7b7b58b1dd. --- askama_derive/src/generator.rs | 7 ------- testing/tests/simple.rs | 14 -------------- 2 files changed, 21 deletions(-) diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 760a1f6..0f9a2af 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -916,14 +916,7 @@ 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 { diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 55353f5..f0f0a26 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -484,17 +484,3 @@ fn test_num_literals() { "[90, -90, 90, 2, 56, 240, 10.5, 10.5, 100000000000, 105000000000]", ); } - -#[derive(askama::Template)] -#[template(source = "{% let word = s %}{{ word }}", ext = "html")] -struct LetBorrow { - s: String, -} - -#[test] -fn test_let_borrow() { - let template = LetBorrow { - s: "hello".to_owned(), - }; - assert_eq!(template.render().unwrap(), "hello") -} -- cgit