Skip to content

Commit 4404601

Browse files
committed
Implement Rand for longer arrays
1 parent 5e46f61 commit 4404601

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
@@ -657,6 +657,20 @@ macro_rules! impl_as_byte_slice_arrays {
657657
($n:expr, $N:ident, $($NN:ident,)*) => {
658658
impl_as_byte_slice_arrays!($n - 1, $($NN,)*);
659659

660+
impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
661+
fn as_byte_slice_mut(&mut self) -> &mut [u8] {
662+
self[..].as_byte_slice_mut()
663+
}
664+
665+
fn to_le(&mut self) {
666+
self[..].to_le()
667+
}
668+
}
669+
};
670+
(!div $n:expr,) => {};
671+
(!div $n:expr, $N:ident, $($NN:ident,)*) => {
672+
impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*);
673+
660674
impl<T> AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut {
661675
fn as_byte_slice_mut(&mut self) -> &mut [u8] {
662676
self[..].as_byte_slice_mut()
@@ -669,6 +683,7 @@ macro_rules! impl_as_byte_slice_arrays {
669683
};
670684
}
671685
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,);
686+
impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,);
672687

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

0 commit comments

Comments
 (0)