-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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<_>>
.
gengteng, LeSeulArtichaut and llacroix
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.