rand_macros
#[derive(Rand)]
functionality for the rand::Rand
trait.
Usage
Add this to your Cargo.toml
:
[]
= "0.3"
= "0.2"
and this to your crate root:
extern crate rand;
extern crate rand_macros;
Examples
#[derive(Rand)]
can be used on any struct
or enum
where all fields/variants implement rand::Rand
.
Now you can call the Rng::gen()
function on your custom types.
use Rng;
let mut rng = thread_rng;
println!;
println!;