Skip to content

Commit 273d7b6

Browse files
committed
Do not manually implement little endian integer conversion
Instead of manually bulding an integer from bytes, use the `from_le_bytes()` method that all integer types implement.
1 parent 66e75c5 commit 273d7b6

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,7 @@ macro_rules! impl_arbitrary_for_integers {
309309
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
310310
let mut buf = [0; mem::size_of::<$ty>()];
311311
u.fill_buffer(&mut buf)?;
312-
let mut x: $unsigned = 0;
313-
for i in 0..mem::size_of::<$ty>() {
314-
x |= buf[i] as $unsigned << (i * 8);
315-
}
316-
Ok(x as $ty)
312+
Ok(Self::from_le_bytes(buf))
317313
}
318314

319315
#[inline]

0 commit comments

Comments
 (0)