Jump to content

Type Erasure in Rust: Revision history

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

15 November 2025

  • curprev 17:5717:57, 15 November 2025 PC talk contribs 8,650 bytes +8,650 Created page with "There’s a quiet kind of magic in Rust’s type system.
It’s strict, mathematical, and predictable — until you suddenly throw in a Box<dyn Trait>. And then? Everything changes.
The compiler stops knowing exactly what your type is, but still somehow knows how to use it safely. That trick — where Rust hides the actual type information but still lets you call methods — is called type erasure.
It’s what lets you write flexible code like this: fn draw_sh..."