Method in random · Rng coil-stdlib

Rng::bytes

pub fn bytes(int n) -> Vec<byte>
Import
use random::{Rng};
Source: src/random.hy

Returns n pseudo-random bytes (none when n <= 0).

Called on a Rng value as value.bytes(…).

Parameters#

NameType
nint

Returns#

Vec<byte>

Examples#

use random::{Rng};
use tests::assert;
let r = Rng::seeded(9);
assert!(r.bytes(16).len() == 16);
assert!(r.bytes(-1).len() == 0);

See also#

  • Rng: A seeded pseudo-random number generator.
  • Rng::seeded: Creates a generator from seed.
  • Rng::from_time: Creates a generator seeded from the current wall-clock and monotonic time (via coil-time).
  • Rng::next_u64: Returns the next raw value from the generator, a non-negative int.
  • Rng::range: Returns a value in lo..hi (including lo, excluding hi), or lo when hi <= lo.
  • Rng::float: Returns a float in 0.0..1.0.
↑ ↓ navigate ↵ open