Tracking Issue for {Mutex, RwLock, ReentrantLock}::data_ptr
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(mutex_data_ptr)], #![feature(rwlock_data_ptr)], #![feature(reentrant_lock_data_ptr)]
This is a tracking issue for allowing unguarded access to the inner value of a Mutex or RwLock. Previous discussion here: https://github.com/rust-lang/libs-team/issues/531
Public API
// std::sync
impl<T: ?Sized> Mutex<T> {
pub fn data_ptr(&self) -> *mut T;
}
impl<T: ?Sized> RwLock<T> {
pub fn data_ptr(&self) -> *mut T;
}
// This type is unstable under feature `reentrant_lock`
impl<T: ?Sized> ReentrantLock<T> {
pub fn data_ptr(&self) -> *mut T;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Implementation: #140369
- Add examples to documentation
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The implementation is complete in #140369; begin by reviewing that change and the existing Mutex, RwLock, and ReentrantLock API documentation. Add usage examples for data_ptr to the relevant standard-library documentation, then verify the examples build and update the tracking checklist. The unresolved return-type questions and FCP/stabilization steps require library-team review rather than an independent code change.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100