---
source: https://iinventedlight.com/library/notes/rust-traits.md
title: "Rust traits and trait bounds"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Copyright (c) 2010 The Rust Project Developers. Sources: The Rust Project (The Rust Programming Language book), Defining Shared Behavior with Traits - The Rust Programming Language, MIT OR Apache-2.0 (rust-lang/book); The Rust Project (The Rust Programming Language book), Generic Data Types - The Rust Programming Language, MIT OR Apache-2.0 (rust-lang/book)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Rust"
tags: rust, traits, generics
sources:
  - id: S1
    title: "Defining Shared Behavior with Traits - The Rust Programming Language"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch10-02-traits.html
    accessed: 2026-11-04
    license: "MIT OR Apache-2.0 (rust-lang/book)"
  - id: S2
    title: "Generic Data Types - The Rust Programming Language"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch10-01-syntax.html
    accessed: 2026-11-04
    license: "MIT OR Apache-2.0 (rust-lang/book)"
---
# Rust traits and trait bounds

## Short answer
A trait defines shared behavior as a set of method signatures, similar to interfaces elsewhere. Types implement traits with `impl Trait for Type`, and generics use trait bounds (`T: Display`) to accept any type with that behavior. Generic code is monomorphized at compile time, so it is as fast as concrete code. [S1][S2]

```rust
trait Summary { fn summarize(&self) -> String { "(more)".into() } }
fn notify(item: &impl Summary) { println!("{}", item.summarize()); }
```

## Key points
- Traits can provide default method implementations. [S1]
- The orphan rule: you can implement a trait for a type only if the trait or the type is local to your crate. [S1]

## Claims
- id: C1
  claim: A trait defines functionality a type has and can share.
  source: S1
  evidence: "A trait defines the functionality a particular type has and can share with"
- id: C2
  claim: Traits are similar to interfaces in other languages.
  source: S1
  evidence: "Traits are similar to a feature often called interfaces in other"
- id: C3
  claim: Rust performs monomorphization of generic code at compile time.
  source: S2
  evidence: "Rust accomplishes this by performing monomorphization of the code using"
- id: C4
  claim: Generics in signatures prevent code duplication.
  source: S2
  evidence: "more functionality to callers of our function while preventing code duplication."

## Sources
- [S1] Defining Shared Behavior with Traits - The Rust Programming Language. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch10-02-traits.html . License: MIT OR Apache-2.0 (rust-lang/book). Accessed 2026-11-04.
- [S2] Generic Data Types - The Rust Programming Language. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch10-01-syntax.html . License: MIT OR Apache-2.0 (rust-lang/book). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
