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.
 
 
 
 
Augusto db4076584d Add subject and tests for exercise `slices_to_map` 3 years ago
..
README.md Add subject and tests for exercise `slices_to_map` 3 years ago

README.md

slices_to_map

Instructions:

Create a function that borrows two slices and returns a hashmap where the first slice represents the keys and the second represents the values.

Expected Function

pub fn slices_to_map(&[T], &[U]) -> HashMap<&T, &U> {
}

Usage

Here is a program to test your function.

fn main() {
	let keys = ["Olivia", "Liam", "Emma", "Noah", "James"];
	let values = [1, 3, 23, 5, 2];
	println!("{:?}", slices_to_map(&keys, &values));
}

And its output

student@ubuntu:~/[[ROOT]]/test$ cargo run
{"Liam": 3, "James": 2, "Emma": 23, "Noah": 5, "Olivia": 1}
student@ubuntu:~/[[ROOT]]/test$