| Crates.io | simple_rng |
| lib.rs | simple_rng |
| version | 0.4.0 |
| created_at | 2026-01-06 00:07:17.333185+00 |
| updated_at | 2026-01-12 23:34:31.499743+00 |
| description | A simple Linear Congruential Generator (LCG) for pseudo-random numbers |
| homepage | |
| repository | https://github.com/Papaya-Voldemort/SimpleRNG |
| max_upload_size | |
| id | 2024832 |
| size | 16,181 |
A minimal, dependency-free pseudo-random number generator (PRNG) library for Rust, based on a Linear Congruential Generator (LCG).
pcg feature)no_std compatible (default feature: std)Add to your Cargo.toml:
[dependencies]
simple_rng = "0.3.0"
Import and use in your code:
use simple_rng::RNG;
fn main() {
let mut rng = RNG::from_time();
let random_number = rng.gen_range(1, 100);
println!("Random number: {}", random_number);
}
You can select the algorithm at runtime:
use simple_rng::{RNG, Algorithm};
let mut rng = RNG::new(42);
rng.set_algorithm(Algorithm::Lcg); // or Algorithm::Pcg if enabled
RNG::new(seed: u64) - Create with a custom seedRNG::from_time() - Create seeded from system time (requires std feature)RNG::from_entropy() - Generates seed from system entropy (beta, requires std feature)set_algorithm(Algorithm) - Select LCG or PCG (if enabled)next() - Next random u64gen_range(min, max) - Random integer in [min, max]gen_float() - Random float in [0.0, 1.0)gen_bool() - Random booleangen_unsigned(size: u8) - Random unsigned integer (8, 16, 32, 64 bits)gen_signed(size: u8) - Random signed integer (8, 16, 32, 64 bits)pick_random(slice) - Pick random element from slice, returns Option<&T>std (enabled by default): Enables seeding from system time or entropy and other standard library features.pcg: Enables the PCG algorithm for improved randomness.no_std: Use in embedded or constrained environments.2024
https://crates.io/crates/simple_rng
MIT