Skip to content

Commit 3d364e7

Browse files
authored
Use built-in constant instead of a magic number (#18)
In job-security providing functions, it is critically important that they be fully in line with best coding practices. Hence, instead of using a well-known(ish!) hardcoded power of two, use u8::MAX to truncate the u32 into a u8.
2 parents c65a653 + 195eaf0 commit 3d364e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn give_up<T: 'static>() -> Box<T> {
8383
let mut rng = oorandom::Rand32::new(seed());
8484

8585
for _ in 0..size {
86-
v.push((rng.rand_u32() % 256) as u8);
86+
v.push((rng.rand_u32() & u32::from(u8::MAX)) as u8);
8787
}
8888

8989
crate::transmute(v.into_boxed_slice())

0 commit comments

Comments
 (0)