Add safety note on `take`

This commit is contained in:
Nur 2026-02-01 19:35:03 +06:00
parent 08c16c4597
commit a63e2de11c
1 changed files with 2 additions and 0 deletions

View File

@ -75,6 +75,8 @@ impl LocalWaker {
/// If a waker has not been registered, this returns `None`.
#[inline]
pub fn take(&self) -> Option<Waker> {
// SAFETY: This can cause data races if called from a separate thread,
// but `LocalWaker` is `!Send` + `!Sync` so this won't happen.
unsafe { (*self.waker.get()).take() }
}
}