I had the following function in my code:
pub async fn forward_tcp(forward_port: bridge::ForwardPortProxy, cmd: TcpCommand) -> Result<()> {
let mut cmd = cmd;
forward_port
.forward_port(None, &mut cmd.host_address, &mut cmd.target_address)
.await?
.map_err(|x| anyhow!("Failed to establish port forward: {:?}", x))
}
Getting rid of the mut on the second line and making the cmd argument mutable instead resulted in a "Warning: 'cmd' does not need to be mutable" message. Getting rid of the mut entirely caused the program to fail to compile due to the mutable references.
I've not gotten a simpler reproducer to behave this way in isolation.
I had the following function in my code:
Getting rid of the
muton the second line and making thecmdargument mutable instead resulted in a "Warning: 'cmd' does not need to be mutable" message. Getting rid of themutentirely caused the program to fail to compile due to the mutable references.I've not gotten a simpler reproducer to behave this way in isolation.