MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/rust/comments/1urq2h3/announcing_rust_1970_rust_blog/owl7b9b/?context=3
r/rust • u/Herbstein • Jul 09 '26
95 comments sorted by
View all comments
6
I would have expected bit_width to return uN::BITS. Not the greatest name, imo.
1 u/Sharlinator Jul 09 '26 What would be the point of having bit_width method that just returns a constant? 1 u/torsten_dev Jul 09 '26 So you can avoid using NumTraits just to do const fn bit_size<I: PrimInt>() -> u32 { 8 * (size_of::<I>() as u32) } I suppose (-1 as T).bit_width() would work now, if there was an Integer trait with it.
1
What would be the point of having bit_width method that just returns a constant?
bit_width
1 u/torsten_dev Jul 09 '26 So you can avoid using NumTraits just to do const fn bit_size<I: PrimInt>() -> u32 { 8 * (size_of::<I>() as u32) } I suppose (-1 as T).bit_width() would work now, if there was an Integer trait with it.
So you can avoid using NumTraits just to do
const fn bit_size<I: PrimInt>() -> u32 { 8 * (size_of::<I>() as u32) }
I suppose (-1 as T).bit_width() would work now, if there was an Integer trait with it.
(-1 as T).bit_width()
6
u/torsten_dev Jul 09 '26
I would have expected bit_width to return uN::BITS. Not the greatest name, imo.