-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add StringReader, StringWriter, and StringStream #10564
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Assuming we're not checking each byte (which seems reasonable, one could feasibly be streaming 1000 bytes at a time from something and so get split across a codepoint), couldn't the (Similarly, isn't |
Yeah, adding a method to |
I'm on it. Since it hasn't been updated in 4 months, if this is no longer relevant please let me know :D |
I'm not sure this makes a ton of sense to add. Doing the conversion manually is pretty painless: |
@sfackler I see your point. If there is a consensus, we can remove this issue. |
A very similar rfc was postponed, so I'm going to close this for now. These operations are all possible with |
…affate make cast_possible_wrap work correctly for 16 bit {u,i}size These changes make `cast_possible_wrap` aware of the different pointer widths and fixes the implementation to print the correct pointer widths. Fixes rust-lang#9337 changelog: `cast_possible_wrap` does not lint on `u8 as isize` or `usize as i8`, since these can never wrap. `cast_possible_wrap` now properly considers 16 bit pointer size and prints the correct bit widths.
The docs for
std::io::mem
mention that there should be some sort of implementation for strings.The Reader is straightforward.
For Writer, this is tricky, since one cannot just write arbitrary data to a string, it must be UTF-8. Where should the boundary be drawn? Should individual writes be checked for UTF-8ness? Should the writer instead check validity of the underlying string when it is destructed? Should these operate on a
&str
(and thus not be growable), or should they make their own~str
?I'm leaning towards a StringWriter that writes to an internal
~[u8]
, with an explicitfn get_string(self) -> Option<~str>
that destroys the writer and returns the string if it is valid, None otherwise. Or, maybe it should beResult<~str, ~[u8]>
, so the buffer could still be handled if desired.The text was updated successfully, but these errors were encountered: