isaacholt100 / bnum

Arbitrary, fixed size numeric types that extend the functionality of primitive numeric types in Rust.
https://crates.io/crates/bnum
Other
67 stars 8 forks source link

Derive Eq and PartialEq #32

Closed boomshroom closed 9 months ago

boomshroom commented 9 months ago
error: to use a constant of type `BIntD32<4>` in a pattern, `BIntD32<4>` must be annotated with `#[derive(PartialEq, Eq)]`

   = note: the traits must be derived, manual `impl`s are not sufficient
   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details

The manual implementation of Eq and PartialEq prevents the compiler from recognizing their implementation as structural and so forbids pattern matching on const values.

isaacholt100 commented 9 months ago

Thanks for opening this issue @boomshroom! I have now implemented this, and it will be included in v0.9.0, which hopefully will be published in a few days time. The reason why PartialEq is currently manually implemented was so that it could be a const implementation on nightly, but since that feature is no longer available for the time being, I'll just remove it 👍.

isaacholt100 commented 9 months ago

v0.9.0 has just been released which fixes this, so closing this issue. Thanks!