Rng: Uninitialized buffer support - #160365
Open
joshtriplett wants to merge 2 commits into
Open
Conversation
Collaborator
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Since `BorrowedBuf`/`BorrowedCursor` are on their way to stabilization, add support for uninitialized buffers in `Rng`. Add a `fill_buf` method that takes a `BorrowedCursor` and fills it in. Adapt all the system implementations accordingly. Make `fill_bytes` a `final fn` helper, which callers can use but trait implementations ignore in favor of implementing `fill_buf`.
joshtriplett
force-pushed
the
rng-fill-buf
branch
from
August 2, 2026 07:06
4ff96b1 to
0721c72
Compare
joboet
reviewed
Aug 2, 2026
Member
There was a problem hiding this comment.
I don't have a strong opinion on whether the only-fill_buf approach is the best, but can you confirm that T-lang is fine with using final in soon-to-be-stable API? I don't think we can retroactively remove it (since people may rely on the guarantee for soundness), so some final-shaped feature would always need to stay in the language.
Member
Author
Will do. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since
BorrowedBuf/BorrowedCursorare on their way to stabilization,add support for uninitialized buffers in
Rng.Add a
fill_bufmethod that takes aBorrowedCursorand fills it in.Adapt all the system implementations accordingly.
Make
fill_bytesafinal fnhelper, which callers can use buttrait implementations ignore in favor of implementing
fill_buf.I considered making it possible to implement either
fill_bytesorfill_buf, but it doesn't seem especially likely that someone would have afill_bytesimplementation that's at all challenging to convert tofill_buf.