aboutsummaryrefslogtreecommitdiff
path: root/src/yielder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/yielder.rs')
-rw-r--r--src/yielder.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/yielder.rs b/src/yielder.rs
index 1ee523f..597e1c9 100644
--- a/src/yielder.rs
+++ b/src/yielder.rs
@@ -20,7 +20,12 @@ pub(crate) struct Enter<'a, T> {
prev: *mut (),
}
-pub fn pair<T>() -> (Sender<T>, Receiver<T>) {
+// Note: It is considered unsound for anyone other than our macros to call
+// this function. This is a private API intended only for calls from our
+// macros, and users should never call it, but some people tend to
+// misinterpret it as fine to call unless it is marked unsafe.
+#[doc(hidden)]
+pub unsafe fn pair<T>() -> (Sender<T>, Receiver<T>) {
let tx = Sender { _p: PhantomData };
let rx = Receiver { _p: PhantomData };
(tx, rx)
@@ -53,9 +58,9 @@ impl<T> Future for Send<T> {
return Poll::Ready(());
}
- STORE.with(|cell| unsafe {
+ STORE.with(|cell| {
let ptr = cell.get() as *mut Option<T>;
- let option_ref = ptr.as_mut().expect("invalid usage");
+ let option_ref = unsafe { ptr.as_mut() }.expect("invalid usage");
if option_ref.is_none() {
*option_ref = self.value.take();