Rust generics: one definition, many concrete types
Answer: Generics let you write one function or struct definition and then use it with many different concrete data types. The usual type parameter name is T, written in angle brackets.
Why the book introduces them
The book uses generics to create definitions for items such as function signatures or structs.
Those definitions can then be reused with many concrete types.
In a function, the generics go in the signature, where you would usually specify the data types of the parameters and the return value.
The result is more flexible code and less duplication.
Type parameters
Rust by Example treats generics as a way of generalizing types and functionalities to broader cases.
A type parameter is marked generic with angle brackets. <T> is the typical form.
Any type specified as a generic type parameter is generic. Everything else is concrete, or non-generic.
See also
Claims
- id: C1 claim: Generics create definitions you can use with many concrete data types. source: S1 evidence: "use with many different concrete data types"
- id: C2 claim: In a function, you place the generics in the signature where types usually go. source: S1 evidence: "place the generics in the signature of the function"
- id: C3 claim: Generics generalize types and functionalities to broader cases. source: S2 evidence: "generalizing types and functionalities to broader cases"
- id: C4 claim: A type parameter is specified with angle brackets, often written <T>. source: S2 evidence: "specified as generic by the use of angle brackets"
Sources
- [S1] Generic Data Types. The Rust Programming Language. https://doc.rust-lang.org/book/ch10-01-syntax.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.
- [S2] Generics. Rust by Example. https://doc.rust-lang.org/rust-by-example/generics.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Generic Data Types; Rust by Example, Generics. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Generic Data Types; Rust by Example, Generics. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers.
Cite this
iinventedlight. 2026. "Rust generics: one definition, many concrete types." iinventedlight Library, iil:note:vge2h66e, version of 2026-11-23. https://iinventedlight.com/library/notes/rust-generics/. License: CC-BY-4.0.
@misc{iil_note_vge2h66e,
author = {{iinventedlight}},
title = {{Rust generics: one definition, many concrete types}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/rust-generics/},
note = {Permanent ID iil:note:vge2h66e. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- rust-generics.schema.json (schema; CC-BY-4.0)
- rust-generics.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/rust-generics.md.