rust-lang / rust-lang/rfcs

Making `MutexGuard`, `RwLockReadGuard` & `RwLockWriteGuard` more generic

Open
#3,377 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Currently, the locks guards are defined like this:

pub struct MutexGuard<'a, T: ?Sized + 'a> {
    lock: &'a Mutex<T>,
    poison: poison::Guard,
}

But there are a lot of instances where taking a reference to the lock is not as versatile as it could be, so perhaps a redefinition of the locks to something like this makes more sense.

pub struct OwnedMutexGuard<M: Deref<Target = Mutex<T>>, T: ?Sized> {
    lock: M,
    poison: poison::Guard,
}

pub type MutexGuard<'a, T> = OwnedMutexGuard<&'a Mutex<T>, T>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files or tests are named. Start by locating the current MutexGuard, RwLockReadGuard, and RwLockWriteGuard definitions and their construction and usage sites; determine whether generic owned guards and reference-based aliases can be designed consistently, then document the resolved API and compatibility behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.