Skip to content

Support implementing both IntoPrimitive and TryFromPrimitive? #158

Description

@jadebuilds

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!!!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions