Skip to content

Implement Arbitrary for AsMut<[T: Arbitrary]> #291

Open
@cyphar

Description

Because of #265, it's no longer possible to do something like

#[derive(Clone, Debug)]
#[cfg_attr(test, derive(PartialEq, Eq))]
struct Foo {
    foo: ChaChaPolyNonce, // has a BorrowMut<[u8]> impl
}

#[cfg(test)]
impl quickcheck::Arbitrary for Foo {
    fn arbitrary(g: &mut quickcheck::Gen) -> Self {
        let mut foo = ChaChaPolyNonce::default();
        g.fill_bytes(&mut foo); // No more RngCore!
        Self { foo }
    }
}

But it seems as though it would be reasonable to simply have an Arbitrary implementation for &mut [T: Arbitrary] that does fill_bytes internally.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions