About
EasyRandom is a library to help generating random patterns adhering to specific patterns that you want
Suppose we want to generate random strings of pattern "aaaa bbbnnn ccccc" where
- a -> lower case english alphabets
- b -> upper case english alphabets
- c -> Both upper case and lower case english alphabets
- n -> numbers from 0 to 9
- s -> custom characters which you can add
- ' ' -> space
- '_' -> underscore
let mut sp_gen = new;
let output=sp_gen.generate;
// We get the following random generated String
// poxy BOG737 ovKwQ
If we put any other string other then a,b,c,n we get this string as output:
let mut sp_gen = new;
let output=sp_gen.generate; // here 'D' is invalid
// We get this string
// Please use the characters a(lowercase),b(uppercase),c(upper+lower cases),n(numbers) only to generate random strings
We can exclude any characters if we want through passing a char array or a vector
let mut sp_gen = new;
sp_gen.exclude_chars; //removing all the vowels from the generator
for i in 0..10
/*
tfzvy rfb__rq
bvnvt cfq__xl
tyhkq bwt__cd
twttm krw__th
wqwfc zqd__nq
srjcj wys__mg
qfktg bvs__gs
xkqgf smb__rl
xpgwv dcq__zd
kclkc ggf__vx
*/
//
You can exclude numbers also
let mut sp_gen = new;
sp_gen.exclude_chars; //removing all the vowels from the generator
for i in 0..10
/*
rjicw0005
xjgak6067
ihxfw8705
ptlxt8085
pvdcx8788
pkmga6707
xakoy6080
amxyl8608
bkbaz6700
uuluz5785
*/
Usage
You can add it from the terminal
You can also add this to TOML file
[dependencies]
easy_random = "0.2.5"
Here is the full sample code
use EasyRandom;
Todo
function exclude some charactersAdd special characters