-
Notifications
You must be signed in to change notification settings - Fork 312
Open
Description
The page on "Send and Sync" [1] says if you need a type T to be not-Send and/or not-Sync (when it isn't automatically so) you can just negative-implement the trait(s) as follows:
impl !Send for T {}
impl !Sync for T {}
However, no you can't. On the stable toolchain, you will get the following error:
error[E0658]: negative trait bounds are not fully implemented; use marker types for now
...
= note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information
It seems that the "correct" solution for now is to add a PhantomData<S> field where S is some other type which lacks the undesired trait(s) [2].
1: https://doc.rust-lang.org/stable/nomicon/send-and-sync.html
2: https://stackoverflow.com/q/62713667/814422
Metadata
Metadata
Assignees
Labels
No labels