rust-num / num-integer

Integer trait and functions for Rust
Apache License 2.0
180 stars 48 forks source link

Why hiding field of ExtendedGcd? #39

Closed survived closed 2 years ago

survived commented 3 years ago

Noticed that there's no way to construct ExtendedGcd from user code (because of hidden field), and I can't implement Integer::extended_gcd (as I can't construct being returned structure) and I have to use your generic implementation of egcd. Perhaps there should be ExtendedGcd::new() constructor?

cuviper commented 3 years ago

It's just meant as an approximation of the newer #[non_exhaustive] attribute, allowing the possibility of new fields in the future. I'm not sure what else we would want to add though, so maybe we should just remove the hidden field and let it be done.

survived commented 3 years ago

Yep, removing this field makes sense

tspiteri commented 2 years ago

I hit this when trying to implement num_integer::Integer for rug::Integer, and had to use a very ugly hack complete with transmute to create an ExtendedGcd struct.