feat: Add bit_width for unsigned NonZero<T>#148797
Conversation
|
@rustbot label +T-libs-api -T-libs r? libs-api |
|
Can’t this return |
Note that we generally don't add things to If, as @hanna-kruppe mentions, this can return @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
Return `NonZero<u32>` instead of `u32`.
|
@scottmcm In safe Rust, the minimum number of bits required to represent unsigned Based on the comments, I changed the return type of this method from |
|
@rustbot ready |
|
Sure; for unstable seems close enough to fit under the existing unstable library feature. @bors r+ rollup |
Rollup of 7 pull requests Successful merges: - #147171 (recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher) - #147421 (Add check if span is from macro expansion) - #147521 (Make SIMD intrinsics available in `const`-contexts) - #148201 (Start documenting autodiff activities) - #148797 (feat: Add `bit_width` for unsigned `NonZero<T>`) - #148798 (Match <OsString as Debug>::fmt to that of str) - #149082 (autodiff: update formating, improve examples for the unstable-book) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width, r=scottmcm feat: Add `bit_width` for unsigned `NonZero<T>` - Tracking issue: #142326 This pull request adds a method to the unsigned `NonZero<T>` that return the minimum number of bits required to represent a value. This can be achieved by using the `get` method and the methods added in #142328, but I think adding the `NonZero::bit_width` method is useful because it accomplishes the same thing a little more succinctly.
Rollup of 7 pull requests Successful merges: - rust-lang/rust#147171 (recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher) - rust-lang/rust#147421 (Add check if span is from macro expansion) - rust-lang/rust#147521 (Make SIMD intrinsics available in `const`-contexts) - rust-lang/rust#148201 (Start documenting autodiff activities) - rust-lang/rust#148797 (feat: Add `bit_width` for unsigned `NonZero<T>`) - rust-lang/rust#148798 (Match <OsString as Debug>::fmt to that of str) - rust-lang/rust#149082 (autodiff: update formating, improve examples for the unstable-book) r? `@ghost` `@rustbot` modify labels: rollup
…bit-width, r=scottmcm feat: Add `bit_width` for unsigned `NonZero<T>` - Tracking issue: rust-lang#142326 This pull request adds a method to the unsigned `NonZero<T>` that return the minimum number of bits required to represent a value. This can be achieved by using the `get` method and the methods added in rust-lang#142328, but I think adding the `NonZero::bit_width` method is useful because it accomplishes the same thing a little more succinctly.
uint_bit_width#142326This pull request adds a method to the unsigned
NonZero<T>that return the minimum number of bits required to represent a value.This can be achieved by using the
getmethod and the methods added in #142328, but I think adding theNonZero::bit_widthmethod is useful because it accomplishes the same thing a little more succinctly.