For some reason I want my struct to be thread unsafe, so I write code like this:
struct Foo {}
impl !Sync for Foo {}
impl !Send for Foo {}
But the compiler gave me an error like this:
negative trait bounds are not yet fully implemented; use marker types for now
I have no idea on how to do this, but I got a workaround:
struct Bar {
phantom: PhantomData<Rc<()>>,
}
Since Rc
does not implement Sync
and Send
, My struct Bar
will act the same.
My question is:
- Is my workaround actually what the error message wants me to do? (I don't like importing the
Rc
since I don't really use it) - If not, what is the proper way to use a marker to un-implement
Sync
?