pub fn is_ident(s: &str) -> bool
Expand description
Determines if s
represents a valid HCL identifier.
A string is a valid HCL identifier if:
is_id_start
returnstrue
for the first character, andis_id_continue
returnstrue
for all remaining chacters
§Example
assert!(!is_ident(""));
assert!(!is_ident("-foo"));
assert!(!is_ident("123foo"));
assert!(!is_ident("foo bar"));
assert!(is_ident("fööbär"));
assert!(is_ident("foobar123"));
assert!(is_ident("FOO-bar123"));
assert!(is_ident("foo_BAR123"));
assert!(is_ident("_foo"));
assert!(is_ident("_123"));
assert!(is_ident("foo_"));
assert!(is_ident("foo-"));