-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add a render_with_values
method?
#48
Comments
Not possible, however we can add a new API to the |
Do you mean it's not possible because the type of the value passed needs to be available at compile time? Because right now, given a template type #[derive(Template(...))]
struct WithValue {
template: &T,
values: &V,
} except the fields of #[derive(Template(with_value = V, ...))]
struct T {
...
} Making it generic over |
The problem is that we only have access to the fields of the current struct, no other information. So for this feature to work, if it's at runtime, it means that all unknown fields like The other approach I suggested is to instead list values in the template proc-macro directly. Like that, we can still generate the best possible code. However, since it's in a proc-macro, the kind of values which can be used will be limited to booleans, integers, strings, tuples and maybe slices. So I'm not sure if it's a good idea either. It's a tricky feature. |
I have a use case for such a method in |
So, it's like a Sorry, I'm on vacation right now, and I won't give any programming question a deeper thought until next Sunday. :) If you want to, maybe you could tell me / link the lines of code that could use that feature and I'll have a look when I'm back home. |
Nah, please don't answer until you're back from holiday. We can discuss when you're back, there is no hurry (I'm in holiday too, yeay). |
It could allow to create variables with given values before generating the template. Could be useful if there are variables outside of the type.
The text was updated successfully, but these errors were encountered: