The extension would only need one initializer:
public init(randomByteCount: Int, using generator: RandomNumberGenerator? = nil)
But either way, how would such an initializer be implemented? Should a next(_ bytes: UnsafeMutableRawBufferPointer)
method be added to the protocol? This could be in addition to, or instead of, the generic next<T: FixedWidthInteger & UnsignedInteger>() -> T
method. It could even replace the next() -> UInt64
method, but in that case other generators might need to use an internal buffer.
Another suggestion is to rename Random
to DefaultRandomNumberGenerator
. Its property could be renamed from default
to shared
(if using a final class instead of a struct).