DEV Community

Rust's `Send` and `Sync`, but actually the opposite

jmaargh on March 28, 2023

This post is my personal notes for grokking Send and Sync in Rust. It's not formal, and will assume that you're basically familiar with concurrenc...
Collapse
 
abigagli profile image
Andrea Bigagli

Hey, really nice post, I got a lot clearer understanding of the subject now.
Just a little doubt, to be sure I got it right: in the example about Rc, shouldn't it say "This is a handle to a resource that is jointly owned, therefore !Send since (for example) Rc::get_mut is not synchronised. Moreover, Rc has interior mutability for the reference count, which is unsynchronised, so !Sync." (i.e. swap Sync and Send in the sentence)?
Because as I understand it, being a handle to a non-uniquely owned resource whose access is not synchronised is rule #2 for being !Send, and having (unsynchronised) interior mutability is rule #2 for being !Sync, hence the first part of the sentence should be used to prove it's !Send and the second part to prove it's !Sync.

Collapse
 
jmaargh profile image
jmaargh

Good catch, thank you. I'll fix the text.
Sorry for the late reply, I assumed I had email alerts set up but apparently I don't.

Collapse
 
yevgnen profile image
Yevgnen

Same question.

Collapse
 
quackquack profile image
Quack Quack

Thanks @jmaargh. This post explains very well one of the most confused concept in Rust.