pub struct Sender<T> { /* private fields */ }🔬This is a nightly-only experimental API. (
oneshot_channel #143674)Expand description
The sending half of a oneshot channel.
§Examples
#![feature(oneshot_channel)]
use std::sync::oneshot;
use std::thread;
let (sender, receiver) = oneshot::channel();
thread::spawn(move || {
sender.send("Hello from thread!").unwrap();
});
assert_eq!(receiver.recv().unwrap(), "Hello from thread!");Sender cannot be sent between threads if it is sending non-Send types.
ⓘ
#![feature(oneshot_channel)]
use std::sync::oneshot;
use std::thread;
use std::ptr;
let (sender, receiver) = oneshot::channel();
struct NotSend(*mut ());
thread::spawn(move || {
sender.send(NotSend(ptr::null_mut()));
});
let reply = receiver.try_recv().unwrap();Implementations§
Source§impl<T> Sender<T>
impl<T> Sender<T>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Sender<T>
impl<T> RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>where
T: Send,
impl<T> Unpin for Sender<T>
impl<T> UnwindSafe for Sender<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more