generics done

This commit is contained in:
David E. Perez Negron R. 2024-04-26 18:53:07 -06:00
parent bfe2e1d8f0
commit 5a374a4588
2 changed files with 5 additions and 7 deletions

View File

@ -6,9 +6,8 @@
// Execute `rustlings hint generics1` or use the `hint` watch subcommand for a // Execute `rustlings hint generics1` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
let mut shopping_list: Vec<?> = Vec::new(); let mut shopping_list: Vec<&str> = Vec::new();
shopping_list.push("milk"); shopping_list.push("milk");
} }

View File

@ -6,14 +6,13 @@
// Execute `rustlings hint generics2` or use the `hint` watch subcommand for a // Execute `rustlings hint generics2` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
struct Wrapper { struct Wrapper<T> {
value: u32, value: T,
} }
impl Wrapper { impl<T> Wrapper<T> {
pub fn new(value: u32) -> Self { pub fn new(value: T) -> Self {
Wrapper { value } Wrapper { value }
} }
} }