diff --git a/Sources/RandomKit/Types/RandomGenerator/ChaCha.swift b/Sources/RandomKit/Types/RandomGenerator/ChaCha.swift index 89fa40f..98309c9 100644 --- a/Sources/RandomKit/Types/RandomGenerator/ChaCha.swift +++ b/Sources/RandomKit/Types/RandomGenerator/ChaCha.swift @@ -32,7 +32,7 @@ /// [1]: http://cr.yp.to/chacha.html /// [2]: https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant /// [3]: https://doc.rust-lang.org/rand/rand/chacha/struct.ChaChaRng.html -public struct ChaCha: RandomBytesGenerator, SeedableFromRandomGenerator { +public struct ChaCha: RandomBytesGenerator, Seedable, SeedableFromRandomGenerator { private typealias _State = _Array16 diff --git a/Sources/RandomKit/Types/RandomGenerator/MersenneTwister.swift b/Sources/RandomKit/Types/RandomGenerator/MersenneTwister.swift index 7dc3933..10c22b2 100644 --- a/Sources/RandomKit/Types/RandomGenerator/MersenneTwister.swift +++ b/Sources/RandomKit/Types/RandomGenerator/MersenneTwister.swift @@ -28,7 +28,7 @@ /// A generator that uses the [Mersenne Twister][MT] algorithm. /// /// [MT]: https://en.wikipedia.org/wiki/Mersenne_Twister -public struct MersenneTwister: RandomBytesGenerator, SeedableFromRandomGenerator { +public struct MersenneTwister: RandomBytesGenerator, Seedable, SeedableFromRandomGenerator { /// The number of `UInt64` values in a `_State`. private static let _stateCount: Int = 312 diff --git a/Sources/RandomKit/Types/RandomGenerator/Seedable.swift b/Sources/RandomKit/Types/RandomGenerator/Seedable.swift index d635df0..328e5e7 100644 --- a/Sources/RandomKit/Types/RandomGenerator/Seedable.swift +++ b/Sources/RandomKit/Types/RandomGenerator/Seedable.swift @@ -49,7 +49,7 @@ extension Seedable { } /// A type that can be seeded by another `randomGenerator`. -public protocol SeedableFromRandomGenerator: Seedable, Random { +public protocol SeedableFromRandomGenerator: Random { /// The default byte threshold at which `self` is reseeded in a `ReseedingRandomGenerator`. static var reseedingThreshold: Int { get } @@ -105,7 +105,7 @@ extension RandomGenerator where Self: SeedableFromRandomGenerator { } -extension Seedable where Seed: Random { +extension Seedable where Self: SeedableFromRandomGenerator, Seed: Random { /// Creates an instance seeded with `randomGenerator`. public init(seededWith randomGenerator: inout R) { @@ -113,12 +113,3 @@ extension Seedable where Seed: Random { } } - -extension Seedable where Self: Random, Seed: Random { - - /// Generates a random value of `Self` using `randomGenerator`. - public static func random(using randomGenerator: inout R) -> Self { - return Self(seededWith: &randomGenerator) - } - -} diff --git a/Sources/RandomKit/Types/RandomGenerator/Xoroshiro.swift b/Sources/RandomKit/Types/RandomGenerator/Xoroshiro.swift index a6910f1..6d5cb6a 100644 --- a/Sources/RandomKit/Types/RandomGenerator/Xoroshiro.swift +++ b/Sources/RandomKit/Types/RandomGenerator/Xoroshiro.swift @@ -31,7 +31,7 @@ /// /// [1]: http://xoroshiro.di.unimi.it/ /// [2]: http://xoroshiro.di.unimi.it/xoroshiro128plus.c -public struct Xoroshiro: RandomBytesGenerator, SeedableFromRandomGenerator { +public struct Xoroshiro: RandomBytesGenerator, Seedable, SeedableFromRandomGenerator { /// A default global instance seeded with `DeviceRandom.default`. public static var `default` = seeded diff --git a/Sources/RandomKit/Types/RandomGenerator/Xorshift.swift b/Sources/RandomKit/Types/RandomGenerator/Xorshift.swift index d952fad..e0f1c2c 100644 --- a/Sources/RandomKit/Types/RandomGenerator/Xorshift.swift +++ b/Sources/RandomKit/Types/RandomGenerator/Xorshift.swift @@ -31,7 +31,7 @@ /// /// [1]: http://www.jstatsoft.org/v08/i14/paper /// [2]: https://doc.rust-lang.org/rand/rand/struct.XorShiftRng.html -public struct Xorshift: RandomBytesGenerator, SeedableFromRandomGenerator { +public struct Xorshift: RandomBytesGenerator, Seedable, SeedableFromRandomGenerator { /// A default global instance seeded with `DeviceRandom.default`. public static var `default` = seeded diff --git a/Sources/RandomKit/Types/RandomGenerator/XorshiftStar.swift b/Sources/RandomKit/Types/RandomGenerator/XorshiftStar.swift index 8e66565..7a3c2cc 100644 --- a/Sources/RandomKit/Types/RandomGenerator/XorshiftStar.swift +++ b/Sources/RandomKit/Types/RandomGenerator/XorshiftStar.swift @@ -28,7 +28,7 @@ /// A generator that uses the [Xorshift1024*][1] algorithm. /// /// [1]: http://xoroshiro.di.unimi.it/xorshift1024star.c -public struct XorshiftStar: RandomBytesGenerator, SeedableFromRandomGenerator { +public struct XorshiftStar: RandomBytesGenerator, Seedable, SeedableFromRandomGenerator { /// The seed type. public typealias Seed = (