Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/not-fl3/quad-rand
https://github.com/not-fl3/quad-rand
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/not-fl3/quad-rand
- Owner: not-fl3
- Created: 2020-03-18T15:44:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-13T13:11:03.000Z (about 2 months ago)
- Last Synced: 2024-10-14T22:11:41.934Z (25 days ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 13
- Watchers: 5
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-quads - quad-rand - wasm-friendly random number generator for quads. (Libraries / Libraries: Other)
README
# quad-rand
[![Crates.io version](https://img.shields.io/crates/v/quad-rand.svg)](https://crates.io/crates/quad-rand)
[![Documentation on docs.rs](https://docs.rs/quad-rand/badge.svg)](https://docs.rs/quad-rand)`quad-rand` implements pseudo-random generator http://www.pcg-random.org/download.html based on rust atomics.
Compatible with wasm and also no-std compatible.
Basic usage, no dependencies involved:
```rust
use quad_rand as qrand;// seed random
qrand::srand(12345);// get random number from 0 to u32::MAX
let x = qrand::rand();// get random number from given range
let x = qrand::gen_range(0., 1.);
assert!(x >= 0. && x < 1.);// gen_range works for most of standard number types
let x: u8 = qrand::gen_range(64, 128);
assert!(x >= 64 && x < 128);
```Optional compatibility layer with `rand` crate:
```rust
use quad_rand::compat::QuadRand;
use rand::seq::SliceRandom;let mut vec = vec![1, 2, 3, 4, 5, 6];
// QuadRand is rand::RngCore implementation, allowing to use all the cool stuff from rand
vec.shuffle(&mut QuadRand);```