fn is_valid(s: &str) -> bool {
    fn is_underscore_alpha_or_digit(c: char) -> bool {
        matches!(c, '_' | 'a'..='z' | 'A'..='Z' | '0'..='9')
    }

    if s == "<SELF>" {
        return true;
    }
    let len = s.len();
    let mut chars = s.chars();
    match chars.next() {
        Some('a'..='z') | Some('A'..='Z') => chars.all(is_underscore_alpha_or_digit),
        Some('_') if len > 1 => chars.all(is_underscore_alpha_or_digit),
        _ => false,
    }
}
/// Describes what identifiers are allowed.
///
/// For now this is deliberately restrictive -- we would like to evolve this in the future.
// TODO: "<SELF>" is coded as an exception. It should be removed once CompiledScript goes away.
Describes what identifiers are allowed.
For now this is deliberately restrictive -- we would like to evolve this in the future.
TODO: "" is coded as an exception. It should be removed once CompiledScript goes away.
Describes what identifiers are allowed . For now this is deliberately restrictive -- we would like to evolve this in the future . TODO : " " is coded as an exception . It should be removed once CompiledScript goes away .
fn is_valid(s: &str) -> bool {
    fn is_underscore_alpha_or_digit(c: char) -> bool {
        matches!(c, '_' | 'a'..='z' | 'A'..='Z' | '0'..='9')
    }
    if s == "<SELF>" {
        return true;
    }
    let len = s.len();
    let mut chars = s.chars();
    match chars.next() {
        Some('a'..='z') | Some('A'..='Z') => chars.all(is_underscore_alpha_or_digit),
        Some('_') if len > 1 => chars.all(is_underscore_alpha_or_digit),
        _ => false,
    }
}
fn is_valid ( s : & str ) -> bool { fn is_underscore_alpha_or_digit ( c : char ) -> bool { matches ! ( c '_' 'a' 'z' 'A' 'Z' '0' '9' ) } if s == " " { return true ; } let len = s . len ( ) ; let mut chars = s . chars ( ) ; match chars . next ( ) { Some ( 'a' ..= 'z' ) | Some ( 'A' ..= 'Z' ) => chars . all ( is_underscore_alpha_or_digit ) , Some ( '_' ) if len > 1 => chars . all ( is_underscore_alpha_or_digit ) , _ => false , } }
Describes what identifiers are allowed.
Describes what identifiers are allowed .
s
&str
s
&str