std: Expose get_mut() on I/O wrappers#14785
std: Expose get_mut() on I/O wrappers#14785alexcrichton wants to merge 1 commit intorust-lang:masterfrom
Conversation
Currently, it is impossible to reset the timeout on a TCP socket inside of a buffered writer or a buffered stream. This is because the method requires `&mut self`, but the buffered objects only provide shared access to the contained object. By allowing mutable access, the possibility for corruption of the stream is exposed. The tradeoff is that many on-the-fly configuration methods are now possible without having to unwrap the buffered streams.
|
I was hitting a similar type-system situation recently where I couldn't call I wonder if I/O is meant for an interior-mutability world, or if there are some yet-undiscovered Rusty abstractions that would be better for I/O. Mutating inner I/O objects scares me: is there any chance this could lead to memory unsafety? |
|
This may also mean that some of our signatures are wrong. Perhaps |
|
cc me |
|
I talked with @aturon tonight at great length about this, and we came to the conclusion that this is likely not the right approach. I will need to think some more before submitting another attempt at this. |
Update "Changelog update walkthrough" section based on rust-lang/rust-clippy#14748 discussion changelog: none
Currently, it is impossible to reset the timeout on a TCP socket inside of a
buffered writer or a buffered stream. This is because the method requires
&mut self, but the buffered objects only provide shared access to the containedobject.
By allowing mutable access, the possibility for corruption of the stream is
exposed. The tradeoff is that many on-the-fly configuration methods are now
possible without having to unwrap the buffered streams.