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
can't use private derive macros #339
Comments
This is a bit of an unfortunate regression. There isn't really a solution to exposing a way to derive traits and add methods on that internal type that doesn't come with the risk of breakage as features are added to I think your best option is to implement the trait manually. It's an ergonomic hit for those cases where you can't add derive support to I would be open though to exploring some way to improve this story in a way that didn't also erode our ability to safely evolve the library. |
This prevents me from upgrading a personal project to 2.0 because I want to be able to use it with bevy_reflect like so: bitflags! {
#[derive(Reflect, FromReflect)]
pub struct MyEnum: u8 { This allows being able to see the values in bevy_egui_inspector and replicating the value over the network using bevy_replicion. My project isn't important, it's just an exercise for myself, but I thought you might want to know about this use case. |
@paul-hansen Since |
Looking at |
I think I've got a solution for this that lets you add custom derives without |
With #348 merged, the |
Starting with version
2
the generated type is a thin wrapper around an internalInternalBitFlags
type that contains all the actual implementations.#[derive(...)]
attributes can only be attached to the external type and not the internal type. This leads to problems for most derive macros because they require the macro to be applied to the internal type as well.One strategy to solve this is to create a cargo feature for each crate that provides such macros and then derive its derive macros on the inner type if the feature is enabled (see #311, #312, #325). Unfortunately this is inherently limited to public crates: This solution does not work for non-public crates that use their own derive macros. I'd like to be able to use my custom derive macros on the internal type without having to publish the derive macro and adding it as a dependency on
bitflags
.The text was updated successfully, but these errors were encountered: