-
Notifications
You must be signed in to change notification settings - Fork 151
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
docs - example of manual arbitrary impl #282
base: master
Are you sure you want to change the base?
Conversation
x: i32, | ||
y: i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use 4 spaces per convention.
any::<(i32, i32)>() // generate 2 arbitrary i32s | ||
.prop_filter_map(|(lower, upper)| { | ||
Range::new(lower, upper) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As caveats, we should probably point to https://altsysrq.github.io/proptest-book/proptest-derive/modifiers.html#filter and also mention that a better implementation would be to swap upper
for lower
when upper < lower
so that filtering is avoided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Do you think it's worth just changing the implementation? It feels weird to have the example and then a comment after saying "actually don't do it like this" when the fix is so trivial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the impl, but also, deriving is powerful enough to express the new impl easily.
@cameron1024 this looks close to done :) @Centril - i'm not sure how else to reach you or @AltSysrq , but it seems that you are the sole owners of proptest-derive still. would either of you be able to update the owners to include the publish team? thanks! |
Added. |
Adds a section to the book for manually implementing
Arbitrary
, addresses #252