mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 05:09:19 +00:00
Added comments to generics2
This commit is contained in:
parent
08fd649796
commit
de77d1b223
@ -3,13 +3,13 @@
|
||||
|
||||
// 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 {
|
||||
value: u32,
|
||||
struct Wrapper<T> { // We modify this to accept any type T, and then we'll implement it down below
|
||||
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 {
|
||||
Wrapper { value }
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user