Why add_template() has a references only parameters? #127
donatengit
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Have you seen the Source type? It lets you load templates dynamically without running into these lifetime issues. The short about why these lifetimes exist is that it allows the compiler and vm internally to borrow out of the loaded source efficiently. To help with this complexity the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Thanks for all your work.
Environment::add_template(&mut self, name: &'source str, source: &'source str) has only referenced parameters and that makes dynamic loading of templates based on some config ('template name'-> 'template filename') a real pain since Rust requires these references to be always valid, thus need to be stored somewhere.
Does it make sense to add implementation supporting move of Strings inside, e.g. add_template(name: String, source: String) as those won't be required anywhere else outside the minijinja?
Beta Was this translation helpful? Give feedback.
All reactions