const SEPARATORS: &[char] = &[' ', '_', '-']; pub fn to_train_case<S: AsRef<str>>(input: S) -> String { let items: Vec<String> = String::from(input.as_ref()) .split(SEPARATORS) .map(ToString::to_string) .collect(); items.join("_").to_uppercase() } #[cfg(test)] mod test { use super::*; #[test] fn test_to_train_case() { assert_eq!(to_train_case("omg-OMG_omg123 omg"), "OMG_OMG_OMG123_OMG") } }