Created
February 16, 2016 08:33
-
-
Save habnabit/adae7b721f8bbc3b199e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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