rustlings/exercises/14_generics/generics1.rs

24 lines
560 B
Rust
Raw Normal View History

// 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.
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);
// }