Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions mea/src/oneshot/mod.rs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already invariant due to UnsafeCell<T>.

Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ use std::fmt;
use std::future::Future;
use std::future::IntoFuture;
use std::hint;
use std::marker::PhantomData;
use std::mem;
use std::mem::MaybeUninit;
use std::pin::Pin;
Expand All @@ -96,19 +95,13 @@ mod tests;
/// Creates a new oneshot channel and returns the two endpoints, [`Sender`] and [`Receiver`].
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
let channel_ptr = NonNull::from(Box::leak(Box::new(Channel::new())));
let sender = Sender {
channel_ptr,
_invariant: PhantomData,
};
let receiver = Receiver { channel_ptr };
(sender, receiver)
(Sender { channel_ptr }, Receiver { channel_ptr })
}

/// Sends a value to the associated [`Receiver`].
#[derive(Debug)]
pub struct Sender<T> {
channel_ptr: NonNull<Channel<T>>,
_invariant: PhantomData<fn(T) -> T>,
}

unsafe impl<T: Send> Send for Sender<T> {}
Expand Down