hcl_primitives::ident

Function is_ident

Source
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:

§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-"));