Open
Description
Suggested by @griesemer in another proposal: #18616 (comment).
An example of the proposed before and after output, for a series of functions called TrailingZeros
with integer sizes "N" as a suffix:
Before:
// TrailingZeros16 returns the number of trailing zero bits in x.
// The result is 16 if x == 0.
func TrailingZeros16(x uint16) uint
// TrailingZeros32 returns the number of trailing zero bits in x.
// The result is 32 if x == 0.
func TrailingZeros32(x uint32) uint
// TrailingZeros64 returns the number of trailing zero bits in x.
// The result is 64 if x == 0.
func TrailingZeros64(x uint64) uint
After:
// TrailingZerosN returns the number of trailing zero bits in a uintN value x for N = 16, 32, 64.
// The result is N if x == 0.
func TrailingZeros16(x uint16) uint
func TrailingZeros32(x uint32) uint
func TrailingZeros64(x uint64) uint
Seems like a big usability improvement, and would be useful in at least sync/atomic
as it exists now in the stdlib: https://golang.org/pkg/sync/atomic/. Would also be useful for some of the proposed APIs for a math/bits
as discussed here: #18616