Skip to content

Instantly share code, notes, and snippets.

@habnabit
Created February 16, 2016 08:33
Show Gist options
  • Save habnabit/adae7b721f8bbc3b199e to your computer and use it in GitHub Desktop.
Save habnabit/adae7b721f8bbc3b199e to your computer and use it in GitHub Desktop.
tests/quickcheck.rs:126:20: 126:21 error: the type parameter `R` is not constrained by the impl trait, self type, or predicates [E0207]
tests/quickcheck.rs:126 impl<T: Arbitrary, R> Arbitrary for T where R: Default + Restriction<T> {
trait Restriction<T> {
fn is_restricted(&mut self, x: &T) -> bool;
}
impl<T: Arbitrary, R> Arbitrary for T where R: Default + Restriction<T> {
fn arbitrary<G: Gen>(g: &mut G) -> T {
let restrictor = R::default();
loop {
let ret = T::arbitrary(g);
if !restrictor.is_restricted(ret) {
return ret;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment