Skip to content

Conversation

yancyribbens
Copy link

Looking for the ability to create an Arbitrary type from a range.

For example, Given a Type:

pub struct A(u64);

Then a type can be created from range with:

impl<'a> Arbitrary<'a> for A {
    fn arbitrary_in_range<T>(u: &mut Unstructured<'a>, range: ops::RangeInclusive<T>) -> Result<Self>
    where
        T: arbitrary::unstructured::Int,
    {
        let a = u.int_in_range(range)?.to_u64();
        Ok(A(a))
    }
}

Marking this as draft to request feedback about adding. Cheers.

@yancyribbens yancyribbens marked this pull request as draft August 31, 2024 17:20
@yancyribbens yancyribbens changed the title Add int in range to trait Add Arbitrary in range to trait Aug 31, 2024
@yancyribbens
Copy link
Author

I just noticed #192 which overlaps with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant