Skip to content
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

Add methods for reading into unitialized buffers #944

Merged
merged 10 commits into from
Dec 7, 2023

Conversation

notgull
Copy link
Contributor

@notgull notgull commented Nov 25, 2023

An alternative to #908 that uses separate functions to enable reading into uninitialized bytes.

So far I've added uninitialized methods for io methods, net methods, and rand. There are other functions that take &mut [u8], but those aren't as pressing for now.

cc #81

Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
@sunfishcode
Copy link
Member

The overall shape here looks good! If, in the future, the standard library adopts some convention for uninitialized buffers, we can follow it.

What would you think about making the doc comments for these new foo_uninit functions just say something like "Like foo, but read into a potentially-uninitialized buffer instead" or so, instead of copying all the documentation content? I know I've done a fair amount of doc-comment copy and pasting myself, but I've been appreciating how shorter comments like this serve to highlight the difference, rather than oblige the reader to carefully compare to full doc comments to find the differences.

Signed-off-by: John Nunley <dev@notgull.net>
@notgull
Copy link
Contributor Author

notgull commented Dec 1, 2023

What would you think about making the doc comments for these new foo_uninit functions just say something like "Like foo, but read into a potentially-uninitialized buffer instead" or so, instead of copying all the documentation content?

I did this. I left behind the header explaining which syscall it corresponds to.

@notgull
Copy link
Contributor Author

notgull commented Dec 7, 2023

@sunfishcode When do you think that you'll be able to review this? I want to implement rustix support for some other crates, but MaybeUninit support is a must for these use cases.

@sunfishcode
Copy link
Member

Sounds good! I'll merge this, do some additional testing, and then cut a new release.

@sunfishcode sunfishcode merged commit 748a828 into bytecodealliance:main Dec 7, 2023
@sunfishcode
Copy link
Member

This is now released in rustix 0.38.27.

@notgull notgull deleted the uninit-slices branch May 21, 2024 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants