A &[Box<String>] has a different representation/layout than &[Box<MatchPathNode>]. Namely, the latter is a slice of trait objects (the box has a fat ptr inside), whereas the former is a slice of normal thin ptrs (inside the box).
You want to change the route1 declaration to:
let route1: Vec<Box<MatchPathNode>> = vec![Box::new(String::from("foo")), Box::new(String::from("bar"))];
// or
let route1 = vec![Box::new(String::from("foo")) as Box<MatchPathNode>, Box::new(String::from("bar"))];
So the compiler knows you’re creating a vec of trait objects.
Thank you! It fixed the compilation issue. Now my concern is about the heavy surface API of the resulting library despite not feature complete yet plus the performance overhead of dynamic dispatch.
What is the convention in the Rust community? Do you think allowing custom behavior make sense for a routing crate or is it better to juste allow an enum of fixed types for the router node declaration?
I’d not worry about performance overhead of dynamic dispatch just yet - it may not matter in the end once you’ve built out the rest of the functionality. You can always redesign later, but at least you’ll have something working to go off and it’ll be a good performance baseline to compare against.