Skip to content

Commit

Permalink
Use built-in constant instead of a magic number
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
antifuchs committed Feb 21, 2024
1 parent d3f6321 commit a696c83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn give_up<T: 'static>() -> Box<T> {
};

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

crate::transmute(v.into_boxed_slice())
Expand Down

0 comments on commit a696c83

Please sign in to comment.