Rng::bytes
pub fn bytes(int n) -> Vec<byte> Import
Source: use random::{Rng}; src/random.hy Returns n pseudo-random bytes (none when n <= 0).
Called on a Rng value as value.bytes(…).
Parameters#
| Name | Type |
|---|---|
n | int |
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 fromseed.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-negativeint.Rng::range: Returns a value inlo..hi(includinglo, excludinghi), orlowhenhi <= lo.Rng::float: Returns afloatin0.0..1.0.