← All notes

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

Sources

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

Permanent ID: iil:note:aadn27h0

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.},
}

Markdown

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.

All artifact files (JSON index)

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.