ixa/random/
macros.rs

1/// Use this to define a unique type which will be used as a key to retrieve  
2/// an independent rng instance when calling `Context::get_rng`.  
3#[macro_export]
4macro_rules! define_rng {
5    ($random_id:ident) => {
6        #[derive(Copy, Clone)]
7        struct $random_id;
8
9        impl $crate::random::RngId for $random_id {
10            type RngType = $crate::rand::rngs::SmallRng;
11
12            fn get_name() -> &'static str {
13                stringify!($random_id)
14            }
15        }
16
17        // This ensures that you can't define two RngIds with the same name
18        $crate::paste::paste! {
19            #[doc(hidden)]
20            #[no_mangle]
21            #[allow(non_upper_case_globals)]
22            pub static [<rng_name_duplication_guard_ $random_id>]: () = ();
23        }
24    };
25}
26pub use define_rng;