-
Notifications
You must be signed in to change notification settings - Fork 226
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 attribute keep_case for NifUnitEnum #263
Comments
What about something more similar to #[derive(NifUnitEnum)]
pub struct KeepCase {
#[rustler(rename = "UPPERCASE")]
uppercase,
lowercase
} I imagine that if we end up adding |
Yes, that would work. Does serde by default rename variants at all, or does it keep them as-is except when |
Wouldn't it make sense to instead work on getting serde_rustler in? I don't see the advantage of a custom codegen right now. |
As this is a small change, I would do this. I am unsure how much work serde_rustler will be. Of course, rustler_serde would be the preferred way. |
Agreed in the context of this crate. I would assume that it wouldn't really be useful outside of rustler anyways. |
Mentioned here: Depending on how willing y'all are to change up rustler and depend directly on serde, a lot of ser/de + encoder/decoder + macro logic could be simplified and/or gotten rid of. The simplest non-breaking change however would be to just copy my |
I started working on integrating this into rustler over the weekend 👍 |
NifUnitEnum
currently expects atoms corresponding to struct fields to be in snake case. This works fine when the user can define the atoms to be in snake case. If that is not possible, e.g. because they are defined by a third party, then decoding them withNifUnitEnum
is not possible.I suggest we add an attribute
keep_case
which defines that the fields are to be used exactly as-is as atoms.The text was updated successfully, but these errors were encountered: