I would like to be able to derive(Arbitrary) on a custom struct that happens to contain various collections that aren't in std (e.g. DashMap, SmallVec). I could add optional dependencies on dashmap and smallvec directly to the arbitrary crate, but I'd prefer to do this more generically so that it works for any collection.
I tried to do that as follows:
impl<'a, T: Arbitrary<'a>, C: FromIterator<T>> Arbitrary<'a> for C {
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
u.arbitrary_iter().collect()
}
}
which didn't work:
1 error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> /Users/jyn/src/arbitrary/src/lib.rs:1158:10
|
1158 | impl<'a, T: Arbitrary<'a>, C: FromIterator<T>> Arbitrary<'a> for C {
| ^ unconstrained type parameter
I have two questions:
- Before I spent more time on it, is this a feature you're interested in?
- Do you have suggestions for how to get it working?
I would like to be able to
derive(Arbitrary)on a custom struct that happens to contain various collections that aren't in std (e.g.DashMap,SmallVec). I could add optional dependencies on dashmap and smallvec directly to thearbitrarycrate, but I'd prefer to do this more generically so that it works for any collection.I tried to do that as follows:
which didn't work:
I have two questions: