Ejercicios 72/94

This commit is contained in:
perro tuerto 2023-03-02 10:11:25 -08:00
parent b6f879f07e
commit 89d303737e
1 changed files with 6 additions and 4 deletions

View File

@ -3,8 +3,6 @@
// can offer. Follow the steps to complete the exercise.
// Execute `rustlings hint iterators2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
// Step 1.
// Complete the `capitalize_first` function.
// "hello" -> "Hello"
@ -21,7 +19,11 @@ pub fn capitalize_first(input: &str) -> String {
// Return a vector of strings.
// ["hello", "world"] -> ["Hello", "World"]
pub fn capitalize_words_vector(words: &[&str]) -> Vec<String> {
vec![]
let mut replaced = vec![];
for word in words.iter() {
replaced.push(capitalize_first(word));
}
replaced
}
// Step 3.
@ -29,7 +31,7 @@ pub fn capitalize_words_vector(words: &[&str]) -> Vec<String> {
// Return a single string.
// ["hello", " ", "world"] -> "Hello World"
pub fn capitalize_words_string(words: &[&str]) -> String {
String::new()
capitalize_words_vector(words).join("")
}
#[cfg(test)]