mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xpetit
32eddefd09
|
4 years ago | |
---|---|---|
.. | ||
README.md | 4 years ago |
README.md
name_initials
Instructions
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 how many times the heap is going to be allocated!
So try your best to allocate the minimum data on the heap!
Notions
Expected Function
pub fn initials(names: Vec<&str>) -> Vec<String> {
}
Usage
Here is a program to test your function:
use name_initials::initials;
fn main() {
let names = vec!["Harry Potter", "Someone Else", "J. L.", "Barack Obama"];
println!("{:?}", initials(names));
}
And its output
student@ubuntu:~/name_initials/test$ cargo run
["H. P.", "S. E.", "J. L.", "B. O."]
student@ubuntu:~/name_initials/test$