rust-lang/rust — pull request #19640 by aliblong (2014-12-08 18:12:37+00:00)
Title: Reform is_power_of_two() to return false for self == 0, and move previous functionality to is_power_of_two_or_zero()

The `is_power_of_two()` method of the `UnsignedInt` trait currently returns `true` for `self == 0`. Zero is not a power of two, assuming positive integral exponents. I've therefore moved this functionality to the new method `is_power_of_two_or_zero()` and reformed `is_power_of_two()` to return false for `self == 0`.

To illustrate the usefulness of the existence of both functions, consider `HashMap`. Its capacity must be zero or a power of two; conversely, it also requires a (non-zero) power of two for key and val alignment.