rand: add missing pub modifiers for .byte() and .u32() methods (#13992)
parent
11d9a67e3b
commit
3f90809035
|
@ -29,7 +29,7 @@ pub fn (mut rng MuslRNG) seed(seed_data []u32) {
|
||||||
|
|
||||||
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
|
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
|
||||||
[inline]
|
[inline]
|
||||||
fn (mut rng MuslRNG) byte() byte {
|
pub fn (mut rng MuslRNG) byte() byte {
|
||||||
if rng.bytes_left >= 1 {
|
if rng.bytes_left >= 1 {
|
||||||
rng.bytes_left -= 1
|
rng.bytes_left -= 1
|
||||||
value := byte(rng.buffer)
|
value := byte(rng.buffer)
|
||||||
|
@ -70,7 +70,7 @@ fn temper(prev u32) u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// u32 returns a pseudorandom 32-bit unsigned integer (`u32`).
|
// u32 returns a pseudorandom 32-bit unsigned integer (`u32`).
|
||||||
fn (mut rng MuslRNG) u32() u32 {
|
pub fn (mut rng MuslRNG) u32() u32 {
|
||||||
rng.state = rng.state * 1103515245 + 12345
|
rng.state = rng.state * 1103515245 + 12345
|
||||||
// We are not dividing by 2 (or shifting right by 1)
|
// We are not dividing by 2 (or shifting right by 1)
|
||||||
// because we want all 32-bits of random data
|
// because we want all 32-bits of random data
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub fn (mut rng PCG32RNG) seed(seed_data []u32) {
|
||||||
|
|
||||||
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
|
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
|
||||||
[inline]
|
[inline]
|
||||||
fn (mut rng PCG32RNG) byte() byte {
|
pub fn (mut rng PCG32RNG) byte() byte {
|
||||||
if rng.bytes_left >= 1 {
|
if rng.bytes_left >= 1 {
|
||||||
rng.bytes_left -= 1
|
rng.bytes_left -= 1
|
||||||
value := byte(rng.buffer)
|
value := byte(rng.buffer)
|
||||||
|
@ -70,7 +70,7 @@ pub fn (mut rng PCG32RNG) u16() u16 {
|
||||||
|
|
||||||
// u32 returns a pseudorandom unsigned `u32`.
|
// u32 returns a pseudorandom unsigned `u32`.
|
||||||
[inline]
|
[inline]
|
||||||
fn (mut rng PCG32RNG) u32() u32 {
|
pub fn (mut rng PCG32RNG) u32() u32 {
|
||||||
oldstate := rng.state
|
oldstate := rng.state
|
||||||
rng.state = oldstate * (6364136223846793005) + rng.inc
|
rng.state = oldstate * (6364136223846793005) + rng.inc
|
||||||
xorshifted := u32(((oldstate >> u64(18)) ^ oldstate) >> u64(27))
|
xorshifted := u32(((oldstate >> u64(18)) ^ oldstate) >> u64(27))
|
||||||
|
|
Loading…
Reference in New Issue