Sync/Send traits for object trait

I have a structure like this:

trait SomeTrait{}
struct A{
    foo: Box<SomeTrait>
}

And I try create a global static variable of A.
But compiler requires Sync implemented for <dyn SomeTrait + 'static>.
How I can do it properly?

I solve:

trait SomeTrait:Sync+Send{}

You can also define the box to have type Box<dyn SomeTrait + Send + Sync + 'static>.

2 Likes

It's a better solution