We have `next_power_of_two`

for the unsigned integer types in Rust. The definition (ignoring overflow):

Returns the smallest power of two greater than or equal to

`self`

.

I propose we add `prev_power_of_two`

with the following definition:

Returns the greatest power of two less than or equal to

`self`

.

In C++20 this pair of functions exists as `bit_ceil`

and `bit_floor`

respectively.

The only small uncertainty I have with this function is what to do in case it gets called on `0`

. I believe that simply returning 0 is the sanest option - this is also what C++20 does.

I propose the following implementation (and similar for other sizes):

```
/// Returns the greatest power of two less than or equal to `self`, or 0 otherwise.
pub const fn prev_power_of_two(n: u64) -> u64 {
// n = 0 gives highest_bit_set_idx = 0.
let highest_bit_set_idx = 63 - (n|1).leading_zeros();
// Binary AND of highest bit with n is a no-op, except zero gets wiped.
(1 << highest_bit_set_idx) & n
}
```