Implement `Arbitrary` for `VecN`.

This commit is contained in:
Sébastien Crozet 2016-03-24 19:03:48 +01:00
parent 88fb33cf44
commit ceed9e52bd
1 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,9 @@ pub struct VecN<N, D: ArrayLength<N>> {
pub at: GenericArray<N, D>
}
unsafe impl<N: Send, D: ArrayLength<N>> Send for VecN<N, D> {
}
impl<N: Clone, D: ArrayLength<N>> Clone for VecN<N, D> {
fn clone(&self) -> VecN<N, D> {
VecN::new(self.at.clone())
@ -109,4 +112,12 @@ impl<N: Copy + Zero, D: ArrayLength<N>> Zero for VecN<N, D> {
}
}
#[cfg(feature="arbitrary")]
impl<N: Arbitrary + Zero + Copy, D: 'static + ArrayLength<N>> Arbitrary for VecN<N, D> {
#[inline]
fn arbitrary<G: Gen>(g: &mut G) -> VecN<N, D> {
(0 .. D::to_usize()).map(|_| Arbitrary::arbitrary(g)).collect()
}
}
vecn_dvec_common_impl!(VecN, D);