checkito/
array.rs

1use crate::{
2    all,
3    generate::{Generate, State},
4};
5use core::array;
6
7#[derive(Clone, Debug)]
8pub struct Array<G: ?Sized, const N: usize>(pub(crate) G);
9
10impl<G: Generate + ?Sized, const N: usize> Generate for Array<G, N> {
11    type Item = [G::Item; N];
12    type Shrink = all::Shrinker<[G::Shrink; N]>;
13
14    fn generate(&self, state: &mut State) -> Self::Shrink {
15        all::Shrinker {
16            index: 0,
17            shrinkers: array::from_fn(|_| self.0.generate(state)),
18        }
19    }
20
21    fn constant(&self) -> bool {
22        N == 0 || self.0.constant()
23    }
24}