-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Support const
evaluation
#169
Comments
Hi, thank you for creating the issue! I tried to test if this is at all possible. I expanded the code for the following macro usage via Rust Analyzer, edited it manually and managed to make it const-compatible: #[derive(bon::Builder)]
struct Point {
x: i32,
y: i32,
} What did I have to change?
What other limitations are anticipatedOther than that I expect the following to never work for
How would the API look like?I imagine having a I can immediately tell that parsing the attribute I fear the problem of parsing |
Thanks for the detailed answer ! if this is not doable now in rust, or would require too much weird behavior within bon, this can be closed (or kept open as a tracking issue for the future). for my case, ill just alloc the struct instead of having a &'static. Have a good day ! |
This is definitely doable, but with some compromises that I think would be obvious to the user. Indeed, let's keep this issue open and track 👍 reactions to see if there is more demand for this. |
the Builder method generated isn't const, and so we can't create use bon when declaring const without using a lazycell.
my use case is im writing a game with a lot of cards, and im declaring the stats of the card in a struct and building with bon.
ideally my Trait Card would have a Card::STATS with my Stats struct.
thanks !
A note for the community from the maintainers
Please vote on this issue by adding a 👍 reaction to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.
The text was updated successfully, but these errors were encountered: