In rust!
pub fn ccbreaker (value: &str) -> String { value.chars() .into_iter() .map(|c| if c.is_uppercase() { format!(" {}", c.to_lowercase()) } else { c.to_string() }) .collect::<String>() } #[cfg(test)] mod tests { use super::*; #[test] fn example_1() { assert_eq!(ccbreaker("camelCasing"), "camel casing".to_string()); } #[test] fn example_2() { assert_eq!(ccbreaker("garbageTruck"), "garbage truck".to_string()); } #[test] fn test_1() { assert_eq!(ccbreaker("policeSiren"), "police siren".to_string()); } #[test] fn test_2() { assert_eq!(ccbreaker("camelCasingTest"), "camel casing test".to_string()); } }
Rust Playground GitHub Gist
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In rust!
Rust Playground
GitHub Gist