Summary

  • Type parameters are placed inside angle brackets

  • Type parameters can be used on structs, functions, impl blocks, and more

  • Type parameters allow you to create placeholders that will be filled in with concrete types, instead of duplicating your definitions

  • Type parameters can be a comma separated list, and are supposed to be UpperCamelCased

  • When you use type parameters to define a struct, you put the angle brackets immediately after the struct’s name

  • When you use type parameters to define a function, you put the angle brackets immediately after the function’s name

  • When you use type parameters in an impl block, you declare the type parameters immediately after the impl keyword, and then use the type parameters in angle brackets with the struct’s name

  • When you need to disambiguate a type, you can use the ::<Turbofish>

Get hands-on with 1200+ tech skills courses.