pub fn exactly_custom_random<F>(length: usize, mut rng: F) -> String
where
    F: FnMut(&mut [u8]),
{
    let mut result = Vec::with_capacity(length);

    let mut chunk = [0; 11];
    'out: while result.len() != result.capacity() {
        rng(&mut chunk);

        for byte in &chunk {
            match ENCODED_TO_UTF8_MAP.get(*byte as usize) {
                Some(v) => result.push(*v),
                None => continue,
            }

            if result.len() == result.capacity() {
                break 'out;
            }
        }
    }

    unsafe { String::from_utf8_unchecked(result) }
}
/// Generates a random G60 string of exactly `length` characters using a custom random generator.
/// Note: depending on the length it can result in a valid G60 encoded string or not.
Generates a random G60 string of exactly `length` characters using a custom random generator.
Note: depending on the length it can result in a valid G60 encoded string or not.
Generates a random G60 string of exactly ` length ` characters using a custom random generator . Note : depending on the length it can result in a valid G60 encoded string or not .
pub fn exactly_custom_random<F>(length: usize, mut rng: F) -> String
where
    F: FnMut(&mut [u8]),
{
    let mut result = Vec::with_capacity(length);
    let mut chunk = [0; 11];
    'out: while result.len() != result.capacity() {
        rng(&mut chunk);
        for byte in &chunk {
            match ENCODED_TO_UTF8_MAP.get(*byte as usize) {
                Some(v) => result.push(*v),
                None => continue,
            }
            if result.len() == result.capacity() {
                break 'out;
            }
        }
    }
    unsafe { String::from_utf8_unchecked(result) }
}
pub fn exactly_custom_random < F > ( length : usize , mut rng : F ) -> String where F : FnMut ( & mut [ u8 ] ) , { let mut result = Vec :: with_capacity ( length ) ; let mut chunk = [ 0 ; 11 ] ; ' out : while result . len ( ) != result . capacity ( ) { rng ( & mut chunk ) ; for byte in & chunk { match ENCODED_TO_UTF8_MAP . get ( * byte as usize ) { Some ( v ) => result . push ( * v ) , None => continue , } if result . len ( ) == result . capacity ( ) { break ' out ; } } } unsafe { String :: from_utf8_unchecked ( result ) } }
Generates a random G60 string of exactly `length` characters using a custom random generator.
Generates a random G60 string of exactly ` length ` characters using a custom random generator .
length
usize
rng
F
length
usize
rng
F