Hello,
I am trying to use a vector of different types without enums, but I get a stackoverflow!
There is no concrete error thrown.
Thank you in advance for your help if you have any idea.
Hello,
I am trying to use a vector of different types without enums, but I get a stackoverflow!
There is no concrete error thrown.
Thank you in advance for your help if you have any idea.
Your blanket DrawClone and Clone for Box<dyn Draw> impls are infinitely mutually recursive for T = Box<dyn Draw> .
This removes the infinite recursion for the impl Clone and at least let's the playground run. (I didn't do any further review at all.)
impl Clone for Box<dyn Draw + Send + Sync> {
fn clone(&self) -> Box<dyn Draw + Send + Sync> {
- self.clone_box()
+ (**self).clone_box()
}
}
That way you call <dyn Draw + ... as DrawClone>::clone_box instead of <Box<dyn Draw + ...> as DrawClone>::clone_box (recursively).
You seemed to get the idea with your impl Draw for Box<dyn Draw + Send + Sync>, so perhaps that's all you needed to understand what's going on, but if not I have an example with more details here.
I should have read your helpful extra doc first.
Thank you for pointing to this example.
I played around a little bit with your example. I removed the "double deref" and got surprisingly no infinite recursion. Why might this be the case here? ![]()
EDIT: Ahh sorry, I was missing the forest through the trees. When I don't call clone it's clear that no infinite recursion happens. ![]()