Skip to content

Commit

Permalink
Merge pull request #14 from Joaopmorais/generics
Browse files Browse the repository at this point in the history
generic exercises
  • Loading branch information
Joaopmorais committed Feb 20, 2024
2 parents fd57c7a + 4a4043f commit 3eadd1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions exercises/14_generics/generics1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,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();
let mut shopping_list: Vec<&str> = Vec::new();
shopping_list.push("milk");
}
10 changes: 5 additions & 5 deletions exercises/14_generics/generics2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// 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 }
}
}
Expand Down

0 comments on commit 3eadd1e

Please sign in to comment.