8
Downcasting Arcs in Rust (ashdnazg.github.io)
you are viewing a single comment's thread
view the rest of the comments
[-] fruitcantfly@programming.dev 3 points 2 days ago* (last edited 2 days ago)

This is horrible in my view. All types that implement Deref and/or DerefMut can be called smart pointers, and everything is “thread-safe” in safe Rust.

If I had to call something “Rust’s thread-safe smart pointer”, it would be the actual references &T/&mut T where T: Send + Sync.

Not everything is thread-safe in safe rust; while safe rust prevents you from using thread-unsafe constructs in a threaded context, most types are not thread-safe. That's why you have both Rc and Arc, since it is not safe to use non-atomic reference counting in a threaded context, but you don't need the overhead of atomics in a non-threaded context.

Nor are references &T/&mut T where T: Send + Sync considered smart pointers in Rust. Those are just references to something that itself implements the traits required to make that type thread-safe.

See also https://doc.rust-lang.org/stable/book/ch15-00-smart-pointers.html and https://doc.rust-lang.org/std/sync/struct.Arc.html#thread-safety

[-] BB_C@programming.dev 1 points 2 days ago

most types are not thread-safe.

Safe rust is thread-safe in the sense that you can't have runtime thread unsafely. If we are going to ignore the role of compile-time errors, then literally nothing is safe.

Also, what is "most"? Can you source that claim?

this post was submitted on 06 Aug 2026
8 points (100.0% liked)

Rust

8202 readers
1 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS