pub(crate) fn sanitize<T: AsRef<str>>(raw: T) -> String {
    let mut escaped = raw
        .as_ref()
        .chars()
        .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
        .peekable();

    let prefix = if escaped.peek().map_or(false, |c| c.is_ascii_digit()) {
        "key_"
    } else if escaped.peek().map_or(false, |&c| c == '_') {
        "key"
    } else {
        ""
    };

    prefix.chars().chain(escaped).take(100).collect()
}
/// sanitize returns a string that is truncated to 100 characters if it's too
/// long, and replaces non-alphanumeric characters to underscores.
sanitize returns a string that is truncated to 100 characters if it's too
long, and replaces non-alphanumeric characters to underscores.
sanitize returns a string that is truncated to 100 characters if it ' s too long and replaces non - alphanumeric characters to underscores .
pub(crate) fn sanitize<T: AsRef<str>>(raw: T) -> String {
    let mut escaped = raw
        .as_ref()
        .chars()
        .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
        .peekable();
    let prefix = if escaped.peek().map_or(false, |c| c.is_ascii_digit()) {
        "key_"
    } else if escaped.peek().map_or(false, |&c| c == '_') {
        "key"
    } else {
        ""
    };
    prefix.chars().chain(escaped).take(100).collect()
}
pub ( crate ) fn sanitize < T : AsRef < str > > ( raw : T ) -> String { let mut escaped = raw . as_ref ( ) . chars ( ) . map ( | c | if c . is_ascii_alphanumeric ( ) { c } else { '_' } ) . peekable ( ) ; let prefix = if escaped . peek ( ) . map_or ( false , | c | c . is_ascii_digit ( ) ) { " " } else if escaped . peek ( ) . map_or ( false , | & c | c == '_' ) { " " } else { " " } ; prefix . chars ( ) . chain ( escaped ) . take ( 100 ) . collect ( ) }
sanitize returns a string that is truncated to 100 characters if it's too
long, and replaces non-alphanumeric characters to underscores.
sanitize returns a string that is truncated to 100 characters if it ' s too long and replaces non - alphanumeric characters to underscores .
raw
T
raw
T