Added comments to generics2

This commit is contained in:
Justin Kelz 2022-05-01 08:33:02 -07:00
parent 08fd649796
commit de77d1b223

View File

@ -3,13 +3,13 @@
// Execute `rustlings hint generics2` for hints! // Execute `rustlings hint generics2` for hints!
// I AM NOT DONE // Looking at the diff of this file and my changes should give enough exposition.
struct Wrapper { struct Wrapper<T> { // We modify this to accept any type T, and then we'll implement it down below
value: u32, value: T,
} }
impl Wrapper { impl<u32> Wrapper<u32> { // so here you'll notice that I provide impl with a type, as I also specify a type for the wrapper, this allows us to handle the u32 case.
pub fn new(value: u32) -> Self { pub fn new(value: u32) -> Self {
Wrapper { value } Wrapper { value }
} }