Not sure how to handler the borrow checker here.
use tokio::sync::oneshot; // 1.0.2
fn main() {
let (sender, receiver) = oneshot::channel::<u8>();
tokio::spawn(async move {
loop {
sender.send(3).unwrap();
}
});
}
Creates this error:
error[E0382]: use of moved value: `sender`
--> src/main.rs:7:13
|
7 | sender.send(3).unwrap();
| ^^^^^^ value moved here, in previous iteration of loop
|
= note: move occurs because `sender` has type `tokio::sync::oneshot::Sender<u8>`, which does not implement the `Copy` trait