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

dyn compatible

A trait simple enough to be used as a trait object.

A trait is dyn compatible (formerly object safe) when every method can be called through a vtable: no generic methods, no Self-returning methods without where Self: Sized, no Sized supertrait.

Examples

  • Adding fn duplicate(&self) -> Self; to Notifier makes Box<dyn Notifier> fail with E0038; adding where Self: Sized to that method makes it compile again.

  • Vec<Box<dyn Clone>> fails with E0038, because clone returns Self.

Read the full section →