Associated function in arbitrary · Gen compiler

Gen::new

pub static fn new(int seed) -> Gen
Import
use arbitrary::{Gen};
Source: compiler/src/prelude/arbitrary.hy

A generator seeded with seed (0 is replaced by a fixed non-zero seed), starting at size 10.

Parameters#

NameType
seedint

Returns#

Gen

Examples#

use arbitrary::Gen;
use tests::assert;
let g = Gen::new(7);
let n = g.int_in(1, 6);
assert!(n >= 1 && n <= 6);

See also#

  • Gen: A seeded source of random values.
  • Gen::size: The current size bound.
  • Gen::resize: Sets the size bound; negative sizes become 0.
  • Gen::bits: 32 random bits.
  • Gen::below: Uniform in [0, n); 0 when n <= 0.
  • Gen::int_in: Uniform in [lo, hi].
  • Gen::one_in: True one time in n.
  • Gen::len: How many elements a collection gets: up to size, none once the value is nested deep().
↑ ↓ navigate ↵ open