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>.


It's a better solution

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.