2023-05-29 20:39:08 +03:00
|
|
|
// generics1.rs
|
|
|
|
//
|
|
|
|
// This shopping list program isn't compiling! Use your knowledge of generics to
|
|
|
|
// fix it.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
fn main() {
|
2024-02-02 18:33:50 +03:00
|
|
|
let mut shopping_list: Vec<&str> = Vec::new();
|
2020-02-28 03:09:08 +03:00
|
|
|
shopping_list.push("milk");
|
|
|
|
}
|
2024-02-02 18:33:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
// fn main() {
|
|
|
|
// let mut shopping_list: Vec<&str> = Vec::new();
|
|
|
|
// // shopping_list.push("milk");
|
|
|
|
// add_to_shopping_list(shopping_list, "milk")
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fn add_to_shopping_list<T>(mut list: Vec<T>, grocery: T) {
|
|
|
|
// list.push(grocery);
|
|
|
|
// }
|