You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to return the first reply packet from a Layer4(Ipv4(IpNextHeaderProtocols::Icmp))transport_channel.
The end of my function is:
let mut rx_iter = icmp_packet_iter(&mut rx);
rx_iter.next()
And I get the following errors:
error[E0515]: cannot return reference to local variable `rx_iter`
--> src\main.rs:29:5
|
29 | rx_iter.next()
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
error[E0515]: cannot return value referencing local variable `rx`
--> src\main.rs:29:5
|
28 | let mut rx_iter = icmp_packet_iter(&mut rx);
| ------- `rx` is borrowed here
29 | rx_iter.next()
| ^^^^^^^^^^^^^^ returns a value referencing data owned by the current function
Apologies if this is a Rust noob question.
I am trying to return the first reply packet from a
Layer4(Ipv4(IpNextHeaderProtocols::Icmp))
transport_channel
.The end of my function is:
And I get the following errors:
The official advice is to "consider returning an owned value instead". How should I do it?
The text was updated successfully, but these errors were encountered: