#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

#662 in Algorithms

Download history 13/week @ 2024-01-29 29/week @ 2024-02-19 31/week @ 2024-02-26 4/week @ 2024-03-11 52/week @ 2024-04-01

56 downloads per month

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

~175KB