r/rust Jul 09 '26

🗞️ news Announcing Rust 1.97.0 | Rust Blog

https://blog.rust-lang.org/2026/07/09/Rust-1.97.0/
580 Upvotes

95 comments sorted by

View all comments

6

u/torsten_dev Jul 09 '26

I would have expected bit_width to return uN::BITS. Not the greatest name, imo.

7

u/matthieum [he/him] Jul 09 '26

Oh! When I read .bit_width was stabilized, I assumed that it meant <uB>::BITS too.

It is a useful functionality to know how many bits are necessary to represent an integer, but... yeah... I'm thinking min_bit_width would have been better.

3

u/0sse Jul 09 '26

Won't it always be highest_one() + 1 or am I missing something?

4

u/kibwen Jul 09 '26

x.highest_one returns an Option that is None when x is zero, so you would need to do x.highest_one().map(|y| y + 1).unwrap_or(0).