2023-04-05 23:10:13 +03:00
|
|
|
// generics1.rs
|
|
|
|
// Use your knowledge of generics to fix the function signature.
|
2020-02-28 03:09:08 +03:00
|
|
|
|
2022-07-14 19:11:05 +03:00
|
|
|
// Execute `rustlings hint generics1` or use the `hint` watch subcommand for a hint.
|
2021-05-11 22:50:05 +03:00
|
|
|
|
2020-02-28 03:09:08 +03:00
|
|
|
// I AM NOT DONE
|
|
|
|
|
2023-04-05 23:10:13 +03:00
|
|
|
fn last_on_list(list: &[&str]) -> &str {
|
|
|
|
list.last().unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not change the main method
|
2020-02-28 03:09:08 +03:00
|
|
|
fn main() {
|
2023-04-05 23:10:13 +03:00
|
|
|
let names_list = vec!["maria", "jacob", "kacper"];
|
|
|
|
println!("last name on the list is: {}", last_on_list(&names_list));
|
|
|
|
|
|
|
|
let numbers_list = vec![1, 2, 3];
|
|
|
|
println!("last number on the list is: {}", last_on_list(&numbers_list));
|
2020-02-28 03:09:08 +03:00
|
|
|
}
|