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

You define `trait Graph { type Node; type Edge; fn nodes(&self) -> Vec<Self::Node>; }`. A caller writes a function generic over any graph but wants to constrain the node type. What is the correct bound syntax?

fn count_named<G>(g: &G) -> usize where G: Graph<Node = String>, { g.nodes().len() }