Skip to content
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 implementing both IntoPrimitive and TryFromPrimitive? #158

Open
jadebuilds opened this issue Dec 29, 2024 · 0 comments
Open

Support implementing both IntoPrimitive and TryFromPrimitive? #158

jadebuilds opened this issue Dec 29, 2024 · 0 comments

Comments

@jadebuilds
Copy link

jadebuilds commented Dec 29, 2024

I want to use both into() and try_from() and I don't see anything in the README indicating that this shouldn't work.

When I try to derive both traits, I get:

error[E0119]: conflicting implementations of trait `TryFrom<i32>` for type `enums::MotionStageState`
  --> src/enums.rs:28:25
   |
28 | #[derive(IntoPrimitive, TryFromPrimitive, PartialEq, PartialOrd, Debug, Clone, Default, Copy)]
   |                         ^^^^^^^^^^^^^^^^
   |
   = note: conflicting implementation in crate `core`:
           - impl<T, U> TryFrom<U> for T
             where U: Into<T>;
   = note: this error originates in the derive macro `TryFromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info)

However! if I try to just derive one or the other, I get errors saying e.g. that the trait bound TryFrom is not satisfied for enums::MotionStageState.

I feel really dumb?? What am I doing wrong? I don't see anything in the docs or issues about this.

I'm currently working around it with #[derive(IntoPrimitive, FromPrimitive)] because that doesn't seem to cause problems, but it's an ugly solution because some of my enums don't really want to have a default value.

I'm using rustc 1.83.0 (90b35a623 2024-11-26) on stable-aarch64-apple-darwin.

Thanks!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant