let mut cloned_wr = cloned.write().unwrap();
for addr in cloned_wr.iter() {
send.send_to(&[1,2,3,4,5], &SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080)).await.unwrap();
//send.send_to(&data, addr).await.unwrap();
println!("sending");
}
}
note: future is not `Send` as this value is used across an await
--> server\src\main.rs:54:21
|
52 | let mut cloned_wr = cloned.write().unwrap();
| ------------- has type `std::sync::RwLockWriteGuard<'_, std::vec::Vec<std::net::SocketAddr>>`
53 | for addr in cloned_wr.iter() {
54 | send.send_to(&[1,2,3,4,5], &SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080)).await.unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here, with `mut cloned_wr` maybe used later
...
58 | }
| - `mut cloned_wr` is later dropped here
Ошибка вызвана cloned_wr, но как исправить?
А там точно write нужен?
Обсуждают сегодня