Merge pull request #688 from GuillaumeGomez/temporary-refs

Add regression test for temporary refs for #661
This commit is contained in:
Guillaume Gomez 2026-01-29 17:34:21 +01:00 committed by GitHub
commit 37264de1a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -437,3 +437,19 @@ mod sub_test {
assert_eq!(Foo { b: 0 }.render().unwrap(), "bar: 0");
}
}
// This test ensures that temporary variables behind references (like one generated
// from `.borrow()`) still work.
//
// Regression test for <https://github.com/askama-rs/askama/issues/661>.
#[test]
fn test_temporary_refs() {
#[derive(Template)]
#[template(
ext = "html",
source = r#"{{ Some("x".to_string().as_str()).unwrap() }}"#
)]
struct Tpl;
assert_eq!(Tpl.render().unwrap(), "x");
}