Closed tibbe closed 1 week ago
You didn't show what error you're getting, but this is basic Rust/borrowing and nothing specific to Askama. You can't put a reference to a locally owned Vec
and return it, because the Vec
will be dropped before the caller gets the result. (You could render the Template
before returning it, or store an owned Vec
in ListPostsTemplate::posts
.)
Assuming some code like this:
I get a borrowing error for
res
(and if I use&res
I get an error for returning a reference to a local variable). Is this supposed to work? If we're not rendering the template before returning it it seems impossible to have rendering depend on any local variables, which I guess is the common case.