flatten_variable_name

Function flatten_variable_name 

Source
pub fn flatten_variable_name(variable_name: impl AsRef<str>) -> String
Expand description

Normalizes a variable name string by performing ASCII transliteration and converting to lowercase.

This uses the [unidecode] crate to approximate non-ASCII characters with their closest ASCII equivalents, and then converts the entire string to lowercase. Then, remove any non-allowed character and consecutive whitespaces, returning the trimmed string.

§Examples

let variable = "  SÉCOND Part ";
let flattened = flatten_variable_name(variable);
assert_eq!(flattened, "second part");