Commit 33a4df4a authored by Alexis Janon's avatar Alexis Janon
Browse files

Random module: one function to generate a random alphanumeric string

Uses the "rand" crate. The generated ascii string is made of
alphanumeric characters up to the given size.
parent 54ed5f12
......@@ -10,4 +10,5 @@ serde_json = "1.0"
log = "0.4"
log4rs = "0.8"
libc = "0.2"
clap = "2.32"
\ No newline at end of file
clap = "2.32"
rand = "0.5"
\ No newline at end of file
......@@ -5,6 +5,7 @@ extern crate log;
extern crate serde_derive;
extern crate libc;
extern crate rand;
extern crate serde;
extern crate serde_json;
......@@ -13,6 +14,7 @@ pub use self::transaction::Command;
pub mod configuration;
pub mod error;
pub mod parsing;
pub mod random;
pub mod result;
pub mod show;
pub mod transaction;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::iter;
pub fn random_string(size: usize) -> String {
let mut rng = thread_rng();
.map(|_| rng.sample(Alphanumeric))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment