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;toNotifiermakesBox<dyn Notifier>fail with E0038; addingwhere Self: Sizedto that method makes it compile again.Vec<Box<dyn Clone>>fails with E0038, becauseclonereturnsSelf.
See also