Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustObject safety rulesSingle-choice MCQ

Why does adding a method that takes a generic parameter bounded by another trait, like `fn process(&self, items: impl IntoIterator<Item = u8>)`, make a trait non-object-safe, while `fn process(&self, items: &dyn Iterator<Item = u8>)` keeps it object-safe?

trait Sink { fn a(&self, items: impl IntoIterator<Item = u8>); // breaks dyn fn b(&self, items: &mut dyn Iterator<Item = u8>); // dyn-ok }