Skip to content

Commit 9a6d897

Browse files
committed
Add data_ptr method to Mutex and RwLock
1 parent 267cae5 commit 9a6d897

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

library/std/src/sync/poison/mutex.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,12 @@ impl<T: ?Sized> Mutex<T> {
608608
let data = self.data.get_mut();
609609
poison::map_result(self.poison.borrow(), |()| data)
610610
}
611+
612+
/// Returns a raw pointer to the underlying data.
613+
#[unstable(feature = "mutex_data_ptr", issue = "140368")]
614+
pub fn data_ptr(&self) -> *mut T {
615+
self.data.get()
616+
}
611617
}
612618

613619
#[stable(feature = "mutex_from", since = "1.24.0")]

library/std/src/sync/poison/rwlock.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ impl<T: ?Sized> RwLock<T> {
634634
let data = self.data.get_mut();
635635
poison::map_result(self.poison.borrow(), |()| data)
636636
}
637+
638+
/// Returns a raw pointer to the underlying data.
639+
#[unstable(feature = "rwlock_data_ptr", issue = "140368")]
640+
pub fn data_ptr(&self) -> *mut T {
641+
self.data.get()
642+
}
637643
}
638644

639645
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)