diff options
| author | Jonas Platte <jplatte+git@posteo.de> | 2025-04-27 16:18:29 +0200 |
|---|---|---|
| committer | Jonas Platte <jplatte+git@posteo.de> | 2025-05-21 08:07:43 +0200 |
| commit | 9efad3a87bb69ce62f9a5b1703e1b8decfe5c4a6 (patch) | |
| tree | 96a4abbe7286fdc0e2ed410142e4c95409382e58 /library/std/src/sync/poison | |
| parent | 87b454156998b945cf161c951f0fbc20ac292cf6 (diff) | |
| download | rust-9efad3a87bb69ce62f9a5b1703e1b8decfe5c4a6.tar.gz rust-9efad3a87bb69ce62f9a5b1703e1b8decfe5c4a6.zip | |
Add data_ptr method to Mutex and RwLock
Diffstat (limited to 'library/std/src/sync/poison')
| -rw-r--r-- | library/std/src/sync/poison/mutex.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sync/poison/rwlock.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs index 1c29c619edc..372bf0a3029 100644 --- a/library/std/src/sync/poison/mutex.rs +++ b/library/std/src/sync/poison/mutex.rs @@ -608,6 +608,12 @@ impl<T: ?Sized> Mutex<T> { let data = self.data.get_mut(); poison::map_result(self.poison.borrow(), |()| data) } + + /// Returns a raw pointer to the underlying data. + #[unstable(feature = "mutex_data_ptr", issue = "140368")] + pub fn data_ptr(&self) -> *mut T { + self.data.get() + } } #[stable(feature = "mutex_from", since = "1.24.0")] diff --git a/library/std/src/sync/poison/rwlock.rs b/library/std/src/sync/poison/rwlock.rs index 6976c0a64e2..0b32a2f1be1 100644 --- a/library/std/src/sync/poison/rwlock.rs +++ b/library/std/src/sync/poison/rwlock.rs @@ -634,6 +634,12 @@ impl<T: ?Sized> RwLock<T> { let data = self.data.get_mut(); poison::map_result(self.poison.borrow(), |()| data) } + + /// Returns a raw pointer to the underlying data. + #[unstable(feature = "rwlock_data_ptr", issue = "140368")] + pub fn data_ptr(&self) -> *mut T { + self.data.get() + } } #[stable(feature = "rust1", since = "1.0.0")] |
