|
|
|
@ -5,7 +5,7 @@
|
|
|
|
|
Create a **function** called `initials`, this function will receive a vector of string literals |
|
|
|
|
with names and return a vector of Strings with the initials of each name. |
|
|
|
|
|
|
|
|
|
> This exercise will test the **heap allocation** of your function! |
|
|
|
|
> This exercise will test how many times the **heap is going to be allocated**!\ |
|
|
|
|
> So try your best to allocate the minimum data on the heap! |
|
|
|
|
|
|
|
|
|
### Notions |
|
|
|
@ -15,7 +15,7 @@ with names and return a vector of Strings with the initials of each name.
|
|
|
|
|
### Expected Function |
|
|
|
|
|
|
|
|
|
```rust |
|
|
|
|
pub fn initials(names: &mut Vec<&str>) -> Vec<String> { |
|
|
|
|
pub fn initials(names: Vec<&str>) -> Vec<String> { |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
@ -27,8 +27,8 @@ Here is a program to test your function:
|
|
|
|
|
use name_initials::initials; |
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
|
|
let mut names = vec!["Harry Potter", "Someone Else", "J. L.", "Barack Obama"] |
|
|
|
|
println!("{:?}", initials(&mut names)); |
|
|
|
|
let names = vec!["Harry Potter", "Someone Else", "J. L.", "Barack Obama"] |
|
|
|
|
println!("{:?}", initials(names)); |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|