typeover
rust curriculum

Curriculum Traits & generics Generics exercise 1 · mcq

Generics

Declare a function identity that takes a value of any type T and returns it unchanged. Pick the idiomatic Rust generic function signature.

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.