-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Description
Today I noticed the following code:
let mut x = u1::new(1);
x <<= 1;
println("{x}");
prints 2
, which is an invalid value for u1
.
I looked at the implementation of ShlAssign and saw:
fn shl_assign(&mut self, rhs: T) {
*self = self.mask();
self.0.shl_assign(rhs);
}
I think the mask call should be after the shl_assign
call (or, perhaps, in both places)? If that sounds right, happy to open a PR. There are unit tests for ShlAssign
, but none involve shifting beyond the type's 'size'.
EDIT: Updated the title of this ticket after discovering the current strategy is to mask on read, so the issue isn't with ShlAssign
, but actually with the various display traits. See discussion below.
Metadata
Metadata
Assignees
Labels
No labels