Exercise 4 · Chapter: GenericsRequired+50 XP
Generic Pair
Create a generic struct Pair<A, B> with fields first: A and second: B. Derive Debug. Create a pair of a string and an integer, then print it.
Expected output:
Pair { first: "age", second: 25 }Hints:
struct Pair<A, B> { first: A, second: B }- Use
Pair { first: "age", second: 25 }
rust
fn main() {
}
Output
Run your code to see the output here.