🦀 Generics Solved

This commit is contained in:
asif256000 2023-07-24 01:20:10 +05:30
parent da5b91c999
commit 34bf2e7398
2 changed files with 6 additions and 10 deletions

View File

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

View File

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