Closed
Description
Mutexes are seldom used without an Arc, I propose to add a method Mutex::arc
that returns an Arc<Mutex<_>>
. This would make code more readable and compact almost everywhere mutexes are used. It also makes the intent clearer, as we first think about the Mutex
, not the Arc
when we use one.
// this:
let mutex = Arc::new(Mutex::new(Thing { inner: 0 }));
// would turn into this
let mutex = Mutex::arc(Thing { inner: 0 });
This would also mimic what we already have with the Box::pin
method that return a Pin<Box<_>>
.