Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustassociated types vs genericsSingle-choice MCQ

Compare these two trait designs. What practical capability does the associated-type version (`Container`) have that the generic version (`ContainerG`) lacks?

trait Container { type Item; fn get(&self, i: usize) -> Option<&Self::Item>; } trait ContainerG<T> { fn get(&self, i: usize) -> Option<&T>; }