2020-12-26 21:07:27 +00:00
## name_initials
### Instructions
2022-05-23 08:39:40 +00:00
Create a **function** named `initials` . This function will receive a vector of string literals with names, and return a vector of Strings with the initials of each name.
2020-12-26 21:07:27 +00:00
2022-05-23 17:32:53 +00:00
### Expected Functions
2020-12-26 21:07:27 +00:00
```rust
2021-02-16 18:22:25 +00:00
pub fn initials(names: Vec< & str>) -> Vec< String > {
2020-12-26 21:07:27 +00:00
}
```
2022-05-23 08:39:40 +00:00
> Your heap allocations will be monitored to ensure that you do not make too many allocations, and that your allocations are reasonably sized.
2022-05-23 08:39:22 +00:00
2020-12-26 21:07:27 +00:00
### Usage
2021-02-08 17:51:44 +00:00
Here is a program to test your function:
2020-12-26 21:07:27 +00:00
```rust
use name_initials::initials;
fn main() {
2021-02-17 06:55:41 +00:00
let names = vec!["Harry Potter", "Someone Else", "J. L.", "Barack Obama"];
2021-02-16 18:22:25 +00:00
println!("{:?}", initials(names));
2020-12-26 21:07:27 +00:00
}
```
And its output
```console
2021-04-28 09:47:34 +00:00
$ cargo run
2020-12-26 21:07:27 +00:00
["H. P.", "S. E.", "J. L.", "B. O."]
2021-04-28 09:47:34 +00:00
$
2020-12-26 21:07:27 +00:00
```
2022-05-23 08:39:22 +00:00
### Notions
- [stack and heap ](https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html )