Post

Usually you want a reference to the `dyn Any` inside the box, `&Box<dyn Any>` will unfortunately be a reference to the box itself, just that the box is now unsized to `dyn Any`.

0 reposts9 likes

Ah d'oh, in my head i was assuming you're getting the reference inside the box, didn't even think about getting the reference to the box. That is a massive footgun indeed

Yes, that's reasonable to assume because deref coercions literally let you do that. It's just that the impl Any for Box<dyn Any> causes unsizing coercion to take precedence. We should look into changing this behavior in future editions.