use generic_array::{ArrayLength, GenericArray};
use rand::rand_core::{CryptoRng, Rng};

type ChosenRng = rand::rngs::StdRng;

// Compile-time check: fails to type-check if bounds aren’t met.
const _: () = {
    fn assert_impls<R: Rng + CryptoRng>() {}
    let _ = assert_impls::<ChosenRng>;
};

/// Returns a [`GenericArray`] filled with `N` random bytes.
pub(crate) fn random_generic_byte_array<N: ArrayLength>() -> GenericArray<u8, N> {
    let mut array: GenericArray<u8, N> = GenericArray::default();
    let mut rng: ChosenRng = rand::make_rng();
    rng.fill_bytes(&mut array);
    array
}
