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

Print Anything

Write a generic function print_it<T: std::fmt::Display> that prints any value with a label. Call it with an integer and a string.

Expected output:

Item: 42
Item: hello

Hints:

  • fn print_it<T: std::fmt::Display>(value: T)
  • Use println!("Item: {}", value) inside the function
rust
fn main() {
}
Output
Run your code to see the output here.