The Rust equivalent of C++'s std::shared_mutex is std::sync::RwLock.
RwLock (Reader-Writer Lock) allows multiple readers to access shared data concurrently, or a single writer to have exclusive access. This is similar to how std::shared_mutex works, where multiple threads can acquire a shared lock for reading, but only one thread can acquire an exclusive lock for writing.
For asynchronous contexts, the tokio::sync::RwLock can be used. There's also a shared-mutex crate that provides an RwLock compatible with Condvar (condition variables), which std::sync::RwLock does not directly support on Unix systems.The Rust equivalent of std::shared_mutex in C++ is std::sync::RwLock.
std::sync::RwLock is a synchronization primitive that allows multiple readers to access shared data concurrently, or a single writer to have exclusive access.
For asynchronous programming, tokio::sync::RwLock provides similar functionality. Additionally, the shared-mutex crate offers an RwLock that can be used with Condvar (condition variables).
-# Response generated by gemini-2.5-flash. AI may be incorrect or misleading.