Skip to content

Commit a696c83

Browse files
committed
Use built-in constant instead of a magic number
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.
1 parent d3f6321 commit a696c83

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
@@ -70,7 +70,7 @@ pub fn give_up<T: 'static>() -> Box<T> {
7070
};
7171

7272
for _ in 0..size {
73-
v.push((rng.rand_u32() % 256) as u8);
73+
v.push((rng.rand_u32() & Into::<u32>::into(u8::MAX)) as u8);
7474
}
7575

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

0 commit comments

Comments
 (0)