Skip to content

Commit 9d6c5a8

Browse files
committed
Add more docs to new data_ptr methods
1 parent 9efad3a commit 9d6c5a8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ impl<T: ?Sized> Mutex<T> {
610610
}
611611

612612
/// Returns a raw pointer to the underlying data.
613+
///
614+
/// The returned pointer is always non-null and properly aligned, but it is
615+
/// the user's responsibility to ensure that any reads and writes through it
616+
/// are properly synchronized to avoid data races, and that it is not read
617+
/// or written through after the mutex is dropped.
613618
#[unstable(feature = "mutex_data_ptr", issue = "140368")]
614619
pub fn data_ptr(&self) -> *mut T {
615620
self.data.get()

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,11 @@ impl<T: ?Sized> RwLock<T> {
636636
}
637637

638638
/// Returns a raw pointer to the underlying data.
639+
///
640+
/// The returned pointer is always non-null and properly aligned, but it is
641+
/// the user's responsibility to ensure that any reads and writes through it
642+
/// are properly synchronized to avoid data races, and that it is not read
643+
/// or written through after the lock is dropped.
639644
#[unstable(feature = "rwlock_data_ptr", issue = "140368")]
640645
pub fn data_ptr(&self) -> *mut T {
641646
self.data.get()

0 commit comments

Comments
 (0)