Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

trait bound

A rule on a generic type saying what it must be able to do, like "P must be an output pin".

A trait bound (P: OutputPin) restricts a generic parameter to types implementing a trait, so the generic code may call that trait's methods and works with any conforming type.

Examples

  • fn blink<P: OutputPin>(pin: &mut P) has the trait bound P: OutputPin, so it accepts the fan's esp-hal Output and rejects types that can't be set high.

  • Passing a value whose type doesn't implement OutputPin to that function is a compile error, not a run-time failure.

Read the full section →