askama
askama copied to clipboard
Associated functions on structs with generics are not callable
# rust
struct Foo<const BAR: bool> {}
impl<const BAR: bool> Foo<BAR> {
fn baz() -> String {
String::from("I should get rendered!")
}
}
# template
<p>Let's baz!</p>
<h1>{% Foo::<false>::baz() %}</h1>
The above should yield I should get rendered!
but instead results in a parsing error:
error: problems parsing template source at row 12, column 50 near:
"::<false>::baz() %}</h1>"...
--> src/etc/...
|
111 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
The workaround for now is to add a method in the template struct and call Foo::<false>::baz()
there.
Yeah, I'm not sure I'll want to support this, to avoid leaking too much complexity into the template language.
That's certainly a valid call; I mostly opened an issue in case it was an oversight. Thank you for the response. :)