-
Notifications
You must be signed in to change notification settings - Fork 149
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
fix: functions are now unique types and require casting to function pointers #46
Conversation
OMG. Casting to the right function type for every property call is a major pain. Is there really no other way? |
@BurntSushi Actually, I think there is another way. If we do |
Good news and bad news. The good news is that, in theory, if we add this implementation: impl<T, Args, Result, F> Testable for F where
F: Fn<Args, Result>,
Args: AShow,
Result: Testable,
{
fn result<G: Gen>(&self, g: &mut G) -> TestResult {
// this definition may not be 100% correct
let args = arby(g);
safe(|| self.call(args)).result(g)
}
} And because of auto-tupling, that should let us use functions of "any" arity with (Actually, this "any" arity is bounded by the implementations of The bad news is that because of rust-lang/rust#18835, that blanket implementation collides with the other "specific" implementations (e.g. Would it make sense to land this PR as an interim solution until rust-lang/rust#18835 gets fixed? That issue is a stdlib stabilization blocker so should get fixed relatively soon. Also the ergonomics of the |
That's some really good news---especially the bit about it working with functions of arbitrary arity! Assuming that bug gets fixed. :-)
Agreed. We should definitely keep the build working. Did the travis test fail because the nightly hasn't been updated yet? Also, with respect to the |
Also, in the spirit of |
…ointers This is a [breaking-change] for users of the `quickcheck` function, you'll need to explicitly cast the bare function to a function pointer. For example: ``` rust fn prop(xs: Vec<int>) -> bool { /* .. */ } // Change this line quickcheck(prop) // into this quickcheck(prop as fn(Vec<int>) -> bool) ```
It failed because the
Done! |
fix: functions are now unique types and require casting to function pointers
@japaric Thank you so much! And extra thanks for investigating the function cast issue. :-) |
I'll publish a new release as soon as @gankro publishes a new release of |
@BurntSushi Done :) |
See rust-lang/rust#19891
To test locally I have used this fork of
collect-rs
(Gankra/collect-rs#39), since the original one is still broken with today's nightly.The macro source code could probably use better naming...