File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff 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]
@@ -889,7 +885,8 @@ impl<'a> Arbitrary<'a> for CString {
889885 fn arbitrary ( u : & mut Unstructured < ' a > ) -> Result < Self > {
890886 <Vec < u8 > as Arbitrary >:: arbitrary ( u) . map ( |mut x| {
891887 x. retain ( |& c| c != 0 ) ;
892- Self :: new ( x) . unwrap ( )
888+ // SAFETY: all zero bytes have been removed
889+ unsafe { Self :: from_vec_unchecked ( x) }
893890 } )
894891 }
895892
You can’t perform that action at this time.
0 commit comments