🦀 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.
// I AM NOT DONE
fn main() {
let mut shopping_list: Vec<?> = Vec::new();
shopping_list.push("milk");
let mut shopping_list: Vec<String> = Vec::new();
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.
// I AM NOT DONE
struct Wrapper {
value: u32,
struct Wrapper<T> {
value: T,
}
impl Wrapper {
pub fn new(value: u32) -> Self {
impl<T> Wrapper<T> {
pub fn new(value: T) -> Self {
Wrapper { value }
}
}