camel_case("hello case"); // => "HelloCase"
camel_case("camel case word"); // => "CamelCaseWord"
fn camel_case(str: &str) -> String {
"Test String".to_string()
}
#[test]
fn sample_test() {
assert_eq!(camel_case("test case"), "TestCase");
assert_eq!(camel_case("camel case method"), "CamelCaseMethod");
assert_eq!(camel_case("say hello "), "SayHello");
assert_eq!(camel_case(" camel case word"), "CamelCaseWord");
assert_eq!(camel_case(""), "");
}
fn camel_case(str: &str) -> String {
str.split_whitespace().map(|s|{
let mut v: Vec<char> = s.chars().collect();
v[0] = v[0].to_uppercase().nth(0).unwrap();
v.into_iter().collect()
}).collect::<Vec<String>>().join("")
}
fn camel_case(str: &str) -> String {
str.split_whitespace()
.map(|s| [&s[..1].to_uppercase(), &s[1..]].join(""))
.collect()
}