1
0
Fork 0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-02-21 00:00:04 +03:00
rustlings/exercises/generics/generics3.rs

31 lines
665 B
Rust
Raw Normal View History

2024-07-11 22:47:30 +03:00
// generics3.rs
// Use your knowledge of generics to fix the `last_on_list` function signature.
// Execute `rustlings hint generics3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn last_on_list(list: &[&str]) -> &str {
list.last().unwrap()
}
fn main() {
// You can optionally experiment here.
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn store_str_on_list() {
let names_list = vec!["maria", "jacob", "kacper"];
let last = last_on_list(&names_list);
}
#[test]
fn store_numbers_on_list() {
let numbers_list = vec![1, 2, 3];
let last = last_on_list(&names_list);
}
}