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

Add BitOrAssign etc. to PrimInt #304

Closed
Enyium opened this issue Dec 17, 2023 · 4 comments
Closed

Add BitOrAssign etc. to PrimInt #304

Enyium opened this issue Dec 17, 2023 · 4 comments

Comments

@Enyium
Copy link

Enyium commented Dec 17, 2023

PrimInt already has bounds for BitOr etc. Is it an oversight that the ...Assign variants are missing?

Currently, I can do:

container = container | t;

...but not:

container |= t;

...when t has a PrimInt bound and container is initialized with T::zero().

@cuviper
Copy link
Member

cuviper commented Dec 29, 2023

I think it's because Primint is simply older -- all of the OpAssign traits were "only" stabilized in Rust 1.8.0, and it's a breaking change to add more requirements to PrimInt since it's not a sealed trait. But you could make your own extended trait that requires more, something like:

trait MyPrimInt: PrimInt + BitOrAssign + ... {}
impl<T: PrimInt + BitOrAssign + ...> MyPrimInt for T {}

@Enyium
Copy link
Author

Enyium commented Dec 30, 2023

Don't you gather breaking changes to perform them one day?

@cuviper
Copy link
Member

cuviper commented Dec 31, 2023

In theory, yes, but in practice I'm afraid that a breaking semver bump will fracture the ecosystem, since these traits are often used in others' public APIs.

@Enyium
Copy link
Author

Enyium commented Jan 2, 2024

Hm, I guess I'll close this then.

@Enyium Enyium closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2024
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

2 participants