Can you assert with Option<Box<dyn Trait>>?

Hi, i'm trying to create container wrapper with the similar API to HashMap with trait objects inside. On insert and on remove id like to output Option and assert it similar to how its shown in this doc: but i get an compiler error that == not defined for Option<Box>. Not sure what to do, since Eq, PartialEq didnt solve my problem.

Here's a playground link to an example

You can

    // or `.is_some()`

If you want actual equality operations for Option<T>, you'll need them for T. In this case, that's a Box<dyn Status>, and you would have to decide what it means for those to be equal or not.

I don't know that it's the best way, but here's one way.


Awesome, thanks a lot!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.