Skip to content

Commit ec9adb2

Browse files
authored
Merge pull request #365 from HyeonuPark/master
Implement Rand for longer arrays
2 parents 46443a6 + 4404601 commit ec9adb2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,20 @@ macro_rules! impl_as_byte_slice_arrays {
658658
($n:expr, $N:ident, $($NN:ident,)*) => {
659659
impl_as_byte_slice_arrays!($n - 1, $($NN,)*);
660660

661+
impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
662+
fn as_byte_slice_mut(&mut self) -> &mut [u8] {
663+
self[..].as_byte_slice_mut()
664+
}
665+
666+
fn to_le(&mut self) {
667+
self[..].to_le()
668+
}
669+
}
670+
};
671+
(!div $n:expr,) => {};
672+
(!div $n:expr, $N:ident, $($NN:ident,)*) => {
673+
impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*);
674+
661675
impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
662676
fn as_byte_slice_mut(&mut self) -> &mut [u8] {
663677
self[..].as_byte_slice_mut()
@@ -670,6 +684,7 @@ macro_rules! impl_as_byte_slice_arrays {
670684
};
671685
}
672686
impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,);
687+
impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,);
673688

674689
/// Iterator which will generate a stream of random items.
675690
///

0 commit comments

Comments
 (0)