Thank you.
Back to the cannot move put of socket, a captured variable ..
async fn send_and_recv_repeat(socket: &mut UdpSocket, pdu: &pdu::Buf, out: &mut [u8], repeat:u32) -> SnmpResult {
let mystream = stream::iter(0..repeat) ;
let stream = mystream.filter_map(|_| async move {
Self::send_and_recv(socket, pdu,out).await.ok()
});
pin_mut!(stream) ;
let res = stream.next().await ;
match res {
Some(len) => Ok(len),
None => Err(SnmpError::ReceiveError)
}
}
cannot move out of socket
, a captured variable in an FnMut
closure
move out of socket
occurs hererustc(E0507)
tokio_session.rs(61, 35): captured outer variable
tokio_session.rs(63, 57): move out of socket
occurs here
tokio_session.rs(64, 40): move occurs because socket
has type &mut tokio::net::UdpSocket
, which does not implement the Copy
trait
tokio_session.rs(64, 40): move occurs due to use in generator
cannot move out of out
, a captured variable in an FnMut
closure
move out of out
occurs hererustc(E0507)
tokio_session.rs(61, 75): captured outer variable
tokio_session.rs(63, 57): move out of out
occurs here
tokio_session.rs(64, 52): move occurs because out
has type &mut [u8]
, which does not implement the Copy
trait
tokio_session.rs(64, 52): move occurs due to use in generator
cannot move out of out
, a captured variable in an FnMut
closure