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

type erasure

Hiding a value's real type behind a trait.

Type erasure stores a value as a trait object (Box) so code can hold many types uniformly but can no longer see which one it has without downcasting.

Examples

  • let e: Box<dyn Error> = "x".parse::<u32>().unwrap_err().into(); no longer shows it is a ParseIntError, but e.downcast_ref::<ParseIntError>() returns Some.

Read the full section →