Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment