Add `BigUint::{is, next}_power_of_two()`
These are two more integer methods we don't have on BigUint, which would be nice to have.
Unresolved questions:
- [x] Currently,
next_power_of_twotakesselfby value instead of reference, to prevent unnecessary clones. Is that the right decision? - [x] If we decide to have
next_power_of_twotakeselfby reference, should we add ato_next_power_of_twomethod that takes it by value?
On naming, there are these guidelines between as_, to_, and into_:
https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
There is also the precedent of the next_power_of_two method on the primitive integers, which is not prefixed at all and takes self by value. But those integers are trivially Copy, so they almost never bother with borrowed &self.
There are also a lot of num-traits methods that take &self for the sake of types like BigUint, even when the primitive types would take self by value in almost every case.
So if we want to support both owned and borrowed, I could see either of these options working well:
-
next_power_of_two(self)andto_next_power_of_self(&self) -
next_power_of_two(&self)andinto_next_power_of_self(self)
I'd think it's better to go with the by-value as the default; it seems better to promote the more efficient method as the default and let people switch out of it when they need it.
Is there anything still blocking this being merged?