start rand utils suite
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
25c004f08c
commit
4f5c6de853
3 changed files with 28 additions and 12 deletions
|
@ -1,15 +1,5 @@
|
|||
use rand::prelude::*;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub fn random_string(length: usize) -> String {
|
||||
thread_rng()
|
||||
.sample_iter(&rand::distributions::Alphanumeric)
|
||||
.take(length)
|
||||
.map(char::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Parses the bytes into a string.
|
||||
#[inline]
|
||||
pub fn string_from_bytes(bytes: &[u8]) -> Result<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue