#random #rand #performance #simple #wyrand

no-std fastrand-contrib

Extension functionality for fastrand

1 unstable release

0.1.0 Sep 17, 2023

#1444 in Rust patterns

Download history 15/week @ 2024-03-11 68/week @ 2024-03-18 35/week @ 2024-03-25 67/week @ 2024-04-01 44/week @ 2024-04-08 47/week @ 2024-04-15 71/week @ 2024-04-22 40/week @ 2024-04-29 33/week @ 2024-05-06 22/week @ 2024-05-13 48/week @ 2024-05-20 29/week @ 2024-05-27 37/week @ 2024-06-03 63/week @ 2024-06-10 23/week @ 2024-06-17 36/week @ 2024-06-24

163 downloads per month
Used in 3 crates (2 directly)

Apache-2.0 OR MIT

26KB
444 lines

fastrand

Build License Cargo Documentation

Extension functionality for the fastrand crate.

This crate contains code that may be of some use to users of fastrand. Code contained in this crate is not included in fastrand due to either the niche not being large enough to justify the new functionality or for semver concerns.

Usage

Various functions are exposed in this crate as top-level functions. These manipulate the global thread-local RNG and can be used without any local state. Note that these require the "std" default feature to be enabled.

use fastrand_contrib::f32_range;

let x = f32_range(1.5..3.0);
assert!(x >= 1.5 && x < 3.0);

To extend fastrand::Rng, import the RngExt trait.

use fastrand_contrib::RngExt;

Now, all new methods are available on fastrand::Rng.

use fastrand::Rng;
use fastrand_contrib::RngExt;

let mut rng = Rng::with_seed(0x1234);
let x = rng.f32_range(1.5..3.0);
assert!(x >= 1.5 && x < 3.0);

Features

  • std (enabled by default): Enables the std library. Freestanding functions only work with this feature enabled. Also enables the fastrand/std feature.
  • libm: Uses libm dependency for math functions in no_std environment.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~130KB