Skip to content

Commit

Permalink
Zero bytes using [u8]::fill (#41)
Browse files Browse the repository at this point in the history
Refactor map_zeroed & map_prefix_tuple_zeroed's for loops with the
`[u8]::fill` method.

Resolves #38
  • Loading branch information
MSalah73 authored Oct 10, 2022
1 parent 49fc9ff commit 6aea74e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,7 @@ fn map_zeroed<B: ByteSliceMut, T: ?Sized>(
) -> Option<LayoutVerified<B, T>> {
match opt {
Some(mut lv) => {
for b in lv.0.iter_mut() {
*b = 0;
}
lv.0.fill(0);
Some(lv)
}
None => None,
Expand All @@ -1055,9 +1053,7 @@ fn map_prefix_tuple_zeroed<B: ByteSliceMut, T: ?Sized>(
) -> Option<(LayoutVerified<B, T>, B)> {
match opt {
Some((mut lv, rest)) => {
for b in lv.0.iter_mut() {
*b = 0;
}
lv.0.fill(0);
Some((lv, rest))
}
None => None,
Expand Down

0 comments on commit 6aea74e

Please sign in to comment.