diff options
Diffstat (limited to 'askama_shared')
-rw-r--r-- | askama_shared/src/generator.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index b0489ec..0ce7df3 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -658,6 +658,12 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { ", _loop_item) in ::askama::helpers::TemplateLoop::new(((&{}).into_iter())) {{", expr_code )), + // If accessing a field then it most likely needs to be + // borrowed, to prevent an attempt of moving. + Expr::Attr(..) => buf.writeln(&format!( + ", _loop_item) in ::askama::helpers::TemplateLoop::new(((&{}).into_iter())) {{", + expr_code + )), // Otherwise, we borrow `iter` assuming that it implements `IntoIterator`. _ => buf.writeln(&format!( ", _loop_item) in ::askama::helpers::TemplateLoop::new(({}).into_iter()) {{", |