-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic template types #11
Comments
Should be straightforward. I only handle the |
Nice. I think as long as you detect this case and fail with a better message, this can wait until after you announce the project. |
Nah, might as well fix it now. Shouldn't be too hard to at least fix the simple cases. |
BTW, I think your test as written will not work. There needs to be a trait bound |
Askama should infer the bound, similar to what we do in Serde. This works: #[derive(Serialize, Deserialize)]
struct Test<T> {
t: T,
} |
How does that work in Serde? I'm not sure it would work in Askama, or at least it seems like it would make Askama an order of magnitude more complex than it currently is. This is because Askama templates can require arbitrary complexity from types of fields in the template (which I think is quite a bit different from Serde). |
(That is to say, it would be fairly easy for this specific case, but it seems Hard for the general case.) |
You're right, I did not consider that arbitrary expressions make it not feasible to infer bounds. Either of these should work when using #[derive(Template)]
#[template(path = "test")]
struct Test<T: Display> {
t: T,
} #[derive(Template)]
#[template(path = "test")]
struct Test<T> where T: Display {
t: T,
} |
Yup, I have that covered. |
BTW, I was using |
|
(Added test case in f71b2f0, which I tagged with the wrong issue number by mistake.) |
How feasible would it be to support generic template types?
The text was updated successfully, but these errors were encountered: