pub trait RandomInt {
    fn gen_uint(&mut self, bits: usize) -> Int;
    fn gen_int(&mut self, bits: usize) -> Int;
    fn gen_uint_below(&mut self, bound: &Int) -> Int;
    fn gen_int_range(&mut self, lbound: &Int, ubound: &Int) -> Int;
}
Expand description

Trait for generating random Ints.

Example

Generate a random Int of size 256 bits:

extern crate rand;
extern crate ramp;

use ramp::RandomInt;

fn main() {
    let mut rng = rand::thread_rng();
    let big_i = rng.gen_int(256);
}

Required Methods

Generate a random unsigned Int of given bit size.

Generate a random Int of given bit size.

Generate a random unsigned Int less than the given bound. Fails when the bound is zero or negative.

Generate a random Int within the given range. The lower bound is inclusive; the upper bound is exclusive. Fails when the upper bound is not greater than the lower bound.

Implementors