Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReader and writer should be taken by value #159
Closed
Milestone
Comments
|
Agree |
|
For anyone who wonders what to do now to not move the reader: let f = File::open(f)?;
bincode::deserialize_from(f.by_ref(), infinite)?; // reference is moved, file is not
bincode::deserialize_from(f.by_ref(), infinite)?; // reference is moved, file is not
bincode::deserialize_from(f, infinite)?; // file is moved, you cannot use one further |
This comment was marked as resolved.
This comment was marked as resolved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is obnoxious when reading or writing some IO stream that is used only for bincode.
The standard library implements Read for &mut R and Write for &mut W so if these methods take the argument by value, callers can keep passing &mut like before if they want.