Rng: Uninitialized buffer support - #160365
Conversation
|
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`.
4ff96b1 to
0721c72
Compare
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.
Will do. |
|
|
|
Waiting on #160394 to enter FCP. |
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.