O'Reilly logo
  • Frederic Dumont thinks this is interesting:

io::copy(&mut stream, &mut write_stream)


Cover of Programming Rust


Can also use the double ref trick:
io::copy(&mut &stream, &mut &stream)
as &TcpStream is also Write and Read.
Each &stream is actually a different value, so each mut ref is for a different value, and thus no borrow checker violation.