Hacker News new | ask | show | jobs
by loeg 265 days ago
You can encode mutex holding into the type system in C++ in a very similar way as Rust. E.g., APIs can take folly::Synchronized<T>::RLockedPtr: https://github.com/facebook/folly/blob/76f81836a2ccb6cd3bc7d...
1 comments

Fair enough — you can do that, which is nice, but in Rust it happens automatically. A program that attempts to concurrently mutate the same object without taking a mutex will always fail to compile (unless you hack around this restriction with unsafe) whereas in C++ you have to intentionally build the API that way.