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 think there is an issue with implementation of vec::as_mut_slice() Here in the docs it is suggested that as_mut_slice() can be used to read data into a vec from an IO reader. So, below example should happily read a bunch of bytes from stdin, and print them out to stdout as byte vectors.
Now, actually running this will read nothing into buf, and will not produce errors or warnings.
The reason this is happening is subtle - buf has capacity, but once it is converted into a slice, that slice is actually empty. For this reason, nothing gets read.
The text was updated successfully, but these errors were encountered:
On the same note, should read() even accept empty slices?
alexpyattaev
changed the title
Incorrect operation of vec::as_mut_slice() with binary read
Unexpected operation of vec::as_mut_slice() with binary read
May 10, 2022
I think there is an issue with implementation of vec::as_mut_slice()
Here in the docs it is suggested that as_mut_slice() can be used to read data into a vec from an IO reader. So, below example should happily read a bunch of bytes from stdin, and print them out to stdout as byte vectors.
Now, actually running this will read nothing into buf, and will not produce errors or warnings.
The reason this is happening is subtle - buf has capacity, but once it is converted into a slice, that slice is actually empty. For this reason, nothing gets read.
The text was updated successfully, but these errors were encountered: