+1 - I also pitched this before.
I agree with @dnadoba that this shouldn't require an unsafe buffer, and my first thought was, as @jrose suggested, to use MutableCollection instead. So +1 to that as well.
IMO this API should scale to use-cases such as filling an Array with random bytes or scribbling over a Data, without requiring those developers to use unsafe constructs. If some random number generators can make use of contiguous mutable storage (e.g. because they are C functions provided by the system), they should do so as an implementation detail.
Also, if we're taking a look at the RNG API, I'd also suggest (once again) that we add static member syntax for SystemRandomNumberGenerator. It's annoying to type out, and now that we can infer generic parameters, it would make these functions a lot more ergonomic to read and write:
// We should add this:
extension RandomNumberGenerator where Self == SystemRandomNumberGenerator {
static var system: Self { Self() }
}
// To allow code like this:
func doSomething(rng: some RandomNumberGenerator = .system) {
...
}