typeover
rust curriculum

Curriculum Traits & generics Generics exercise 3 · mcq

Generics

A generic function prints its argument with {}. Pick the trait bound it needs on T.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Rust generics are monomorphized and usually constrained with traits. TypeScript's generic syntax transfers conceptually, but Rust wants bounds where behavior is used. Planned exercises: 1. choose generic function syntax. 2. recognise Vec<T>. 3. choose a trait bound for formatting or comparison. 4. fill <T>. 5. fill T: Clone. 6. write a generic identity function. 7. write a generic container struct. 8. translate a TS generic helper. 9. fix a generic function by adding the smallest required bound.