My take on Send/Sync

Hi everyone!

I've been working with Rust for a while now, and Send/Sync gave me quite a bit of trouble early on.

Whenever I'd try to use certain types across threads, I'd get these compiler errors about Send or Sync not being implemented, and I'd end up finding workarounds without really grasping the fundamental reasons behind these constraints.

After some frustration, I decided to sit down and properly understand what these traits are actually trying to accomplish. This post represents my current understanding of Send/Sync after spending time with the concepts.

I'd appreciate any feedback or corrections. Thank you for reading!

1 Like

Seems pretty good. The one thing I would suggest is to point out that Send and Sync aren’t just independent properties that both have to do with thread safety: &T: Send (and Arc<T>: Send) is conditional on T: Sync. In most cases, we enforce “cannot be shared” using “cannot be sent”.

Yep, you're totally right about that relationship. It's a crucial insight. I actually went back and forth on whether to include it but honestly couldn't figure out how to explain it without making the whole thing way harder (and longer) to follow. Maybe that's my next post. Thanks for pointing it out!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.