I agree with all of the observations you already made, e.g. about the fact that
Deref defeats the purpose of preventing
Sync or that for concrete types one could just “manually write a bunch of wrapper methods”.
you talk about being generic — well in general, the methods of
T could “expose” references to
T themselves directly, so it’s not reasonably to be completely generic. Perhaps a generic approach could be tailored around types
T that implement a fixed/known trait, but even then I’m having a hard time imagining what kind of safety guarantees you are going to achieve in any sort of general setting. For a concrete, fixed/known type
T, the “manually write a bunch of wrapper methods” approach may work, but – at least in case that you control the implementation of
T yourself – I would wonder why
Sync in the first place if you care so much about the fact that it isn’t sync in certain settings. I guess the other way works better; if you provide a wrapper
Sync<T> or even just another type
SyncT that is handed out in situations where sharing between different threads is, for some reason, known to be safe safe. That wrapper or new type could also go the
Deref route then, I guess.
What I’m saying, or perhaps asking, is: Do you have some concrete use case? This sounds like a potential XY problem situation IMO, and even if it isn’t I would be curious what your imagined application or general motivation is behind this question.