Associated types: placeholders on a trait
Answer: An associated type puts a type placeholder on a trait. Each implementor names the concrete type, and method signatures can mention that placeholder.
In the Rust book
The book says associated types connect a type placeholder with a trait.
Trait method definitions can then use these placeholder types inside their signatures.
Implementors supply the concrete type when they implement the trait.
Readability in Rust by Example
Rust by Example says this feature improves overall readability by moving inner types into the trait as output types.
Without using associated types, a function may still have to express A or B.
Using associated types, a function is no longer required to express A or B at all.
See also
Claims
- id: C1 claim: Associated types connect a type placeholder with a trait. source: S1 evidence: "Associated types connect a type placeholder with a trait"
- id: C2 claim: Method definitions can use those placeholder types in their signatures. source: S1 evidence: "placeholder types in their signatures"
- id: C3 claim: Associated types move inner types locally into a trait as output types. source: S2 evidence: "moving inner types locally into a trait as output types"
- id: C4 claim: That move improves the overall readability of code. source: S2 evidence: "improves the overall readability of code"
Sources
- [S1] Advanced Traits. The Rust Programming Language. https://doc.rust-lang.org/book/ch20-02-advanced-traits.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.
- [S2] Associated types. Rust by Example. https://doc.rust-lang.org/rust-by-example/generics/assoc_items/types.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, Advanced Traits; Rust by Example, Associated types. 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, Advanced Traits; Rust by Example, Associated types. 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. "Associated types: placeholders on a trait." iinventedlight Library, iil:note:aadn27h0, version of 2026-11-23. https://iinventedlight.com/library/notes/rust-associated-types/. License: CC-BY-4.0.
@misc{iil_note_aadn27h0,
author = {{iinventedlight}},
title = {{Associated types: placeholders on a trait}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/rust-associated-types/},
note = {Permanent ID iil:note:aadn27h0. 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-associated-types.schema.json (schema; CC-BY-4.0)
- rust-associated-types.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-associated-types.md.