Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upstd: Implement io traits for io::Cursor of Vec references #25118
Conversation
rust-highfive
assigned
aturon
May 5, 2015
This comment has been minimized.
This comment has been minimized.
|
You could use |
This comment has been minimized.
This comment has been minimized.
|
For reading, yes, but for writing, no, because |
This comment has been minimized.
This comment has been minimized.
|
Ah but &mut Vec doesn't need a cursor (its length is the cursor). |
This comment has been minimized.
This comment has been minimized.
|
It does if you want it to be |
This comment has been minimized.
This comment has been minimized.
|
Due to the way stability of trait implementations works, we'd be forced to mark all these with |
alexcrichton
added
the
T-libs
label
May 26, 2015
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Should this be closed? Edit: It occurs to me that doing lazy-sunday triage when we're doing hardcore triage tomorrow is kinda pointless. |
This comment has been minimized.
This comment has been minimized.
|
@Gankro ah yes this has gone a little stale, so I think I'll close this for now. We can always continue to explore these options in the future though! |
ruuda commentedMay 5, 2015
For example,
io::Cursor<&Vec<u8>>did not implementio::Read, whereasio::Cursor<Vec<u8>>did. There might be a good reason for this that I missed, but it is not impossible as this PR demonstrates.Constructing a cursor from a reference is useful when you already have the vector. You can temporarily wrap it in a cursor to read from it or write to it, and continue using the vector when the cursor goes out of scope. There is no need to call
into_inner.I don’t know what the procedure is for stability attributes, so I did not add them yet.
r? @aturon