Open vi opened 3 years ago
Generating recursive types in general is fairly tricky, as anything that could hold more than one child at each level can easily blow up into immense sizes when using the naïve recursive approach (consider what would happen for struct Qqq(Option<Box<Qqq>>, Option<Box<Qqq>>)
).
Basically, this is an expected limitation right now and unless someone comes up with a sensible way for recursive types to be handled in general the limitation won't be going away.
Maybe some #[user] #[annotations] with probabilities for Option
and other enums could help?
Generating recursive types in general is fairly tricky, as anything that could hold more than one child at each level can easily blow up into immense sizes when using the naïve recursive approach (consider what would happen for
struct Qqq(Option<Box<Qqq>>, Option<Box<Qqq>>)
).Basically, this is an expected limitation right now and unless someone comes up with a sensible way for recursive types to be handled in general the limitation won't be going away.
Would it be possible to simply limit the depth of such structures by a constant, taken as an argument by the derive macro (somehow)?
Would it be possible to simply limit the depth of such structures by a constant, taken as an argument by the derive macro (somehow)?
I think this is a valid approach and at least deserves a look.
Expected:
Arbitrary
implementation that generates chains likeQqq(Some(Box(Qqq(Some(Box(Qqq(None)))))))
and shrinks byNone
ing some layers.Actual:> as Arbitrary>::Parameters == _
error[E0271]: type mismatch resolving
<Option<Box,
cyclic type of infinite size`