-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please provide a read_buf_exact
helper
#7127
Comments
Seems reasonable enough to me. I would be happy to see this. |
@joshtriplett I worked on implementing Since these buffers have infinite capacity, it's a misuse of the function to call it like |
Having it in a less prominent place would be OK if necessary, though it might be nice to have a cross-reference to it from The use case I had in mind involves a sized uninitialized buffer, using https://doc.rust-lang.org/std/sync/struct.Arc.html#method.new_uninit_slice . For that purpose, it would be more convenient if the API relies on the existing length. However, I understand that that would be less convenient for growable buffers. This seems like something best handled with either 1) two APIs or 2) a BufMutLen trait or similar, implemented by buffers with a fixed size, not implemented by buffers with an unlimited size, and possibly a |
I've now written a PR for a |
read_buf
allows reading into anyBufMut
, such as an uninitialized buffer; however, it requires dealing with partial reads.read_exact
avoids having to deal with partial reads, but it only accepts an initialized buffer.Please consider adding a
read_buf_exact
that accepts anyBufMut
and avoids having to deal with partial reads.The text was updated successfully, but these errors were encountered: