Exerpad
🔥 0
0 XP
Exercise 2 · Chapter: GenericsRequired+50 XP

Generic Wrapper

Create a generic struct Wrapper<T> with a field value: T. Derive Debug. Create a wrapper holding an integer and another holding a string, then print both.

Expected output:

Wrapper { value: 99 }
Wrapper { value: "Rust" }

Hints:

  • #[derive(Debug)] above the struct
  • struct Wrapper<T> { value: T }
  • Print with {:?}
rust
fn main() {
}
Output
Run your code to see the output here.