You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The trait num::traits::PrimInt mandates that any type implementing it must also implement Shl<usize, Output=Self> and Shr<usize, Output=Self> (in other words, PrimInt mandates that the shift amount be of type usize).
Thus all bit twiddling functions (trailing_zeros, rotate_left, count_zeros etc.) in PrimInt should take or return a usize instead of u32 as the number of bits for the sake of consistency with what the implementation restrictions on Shl and Shr mandate.
I think changing the trait bounds to u32 sounds fine, but it will be a breaking change, which I want to be pretty conservative about. I should start a list somewhere of "things to break" so we can plan to do them all at once.
I've decided to limit the clutter of breaking change issues, so they will now be tracked collectively in #47. I'm closing this issue for now as postponed but we can still discuss its merits here as needed.
From @octurion on April 10, 2015 10:12
The trait
num::traits::PrimInt
mandates that any type implementing it must also implementShl<usize, Output=Self>
andShr<usize, Output=Self>
(in other words,PrimInt
mandates that the shift amount be of typeusize
).Thus all bit twiddling functions (
trailing_zeros
,rotate_left
,count_zeros
etc.) inPrimInt
should take or return ausize
instead ofu32
as the number of bits for the sake of consistency with what the implementation restrictions onShl
andShr
mandate.Copied from original issue: rust-num/num#80
The text was updated successfully, but these errors were encountered: