#random #java #utils #pure #random-seed #class #javarandom-rs

javarandom

Pure rust implementation of java.util.Random

3 unstable releases

0.2.1 Jan 29, 2024
0.2.0 Jan 29, 2024
0.1.0 Apr 11, 2021

#1026 in Algorithms

Unlicense

7KB
96 lines

javarandom-rs

javarandom-rs is a pure Rust implementation of java.util.Random

Example

fn main() {
    let mut rng = JavaRandom::with_seed(1234);

    for i in 0..10 {
        println!("{i}: {}", rng.next_int());
    }
}

lib.rs:

Pure rust implementation of the java.util.Random class.

Examples

use javarandom::JavaRandom;

// Create a JavaRandom instance with a random seed
let mut random = JavaRandom::new();

println!("Random number between 0.0 and 1.0: {}", random.next_float());

Dependencies

~170KB