Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Arbitrary in range to trait #193

Closed

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.

None yet

1 participant