I have a variable write_half with type OwnedWriteHalf, and this code used to work in Tokio 0.x:
write_half.as_ref().shutdown(Shutdown::Both)
But in tokio 1.0, it stops working since write_half.as_ref() returns a TcpStream ref, but shutdown requires a mutable ref. What should I do to access a mutable ref of TcpStream from its OwnedWriteHalf?
Also, be aware that shutdown(Both) is pretty terrible. It has very platform specific-behavior. It is generally only consistently defined what happens if you shut down the write direction.
It is a method from the AsyncWriteExt trait that you can call on anything that implements AsyncWrite. Note that the owned write half also calls the method in its destructor, so an alternative is to just drop it.