#constants #macro #rust

macro const-random-macro

Provides the procedural macro used by const-random

12 releases

new 0.1.12 Nov 21, 2020
0.1.11 Oct 7, 2020
0.1.8 Jan 21, 2020
0.1.6 Aug 6, 2019
0.1.3 Mar 3, 2019

#141 in Algorithms

Download history 42120/week @ 2020-08-04 37733/week @ 2020-08-11 36720/week @ 2020-08-18 38679/week @ 2020-08-25 37732/week @ 2020-09-01 42109/week @ 2020-09-08 40680/week @ 2020-09-15 40137/week @ 2020-09-22 39291/week @ 2020-09-29 42534/week @ 2020-10-06 43789/week @ 2020-10-13 44931/week @ 2020-10-20 41535/week @ 2020-10-27 37067/week @ 2020-11-03 41156/week @ 2020-11-10 39290/week @ 2020-11-17

175,387 downloads per month
Used in 8 crates (via const-random)

MIT/Apache

7KB
121 lines

Random constants

This crate provides compile time random number generation. This allows you to insert random constants into your code that will be auto-generated at compile time.

A new value will be generated every time the file is rebuilt. This obviously makes the resulting binary or lib non-deterministic.

Example

use const_random::const_random  ;
const MY_RANDOM_NUMBER: u32 = const_random!(u32);

This works exactly as through you have called: OsRng.gen::<u32>() at compile time. So for details of the random number generation, see the rand crates documentation.

The following types are supported: u8, i8, u16, i16, u32, i32, u64, i64, u128. i128.

Dependencies

~155KB