diff --git a/src/routing/mod.rs b/src/routing/mod.rs index 56970452..0d54f97e 100644 --- a/src/routing/mod.rs +++ b/src/routing/mod.rs @@ -20,6 +20,7 @@ use std::{ fmt, future::ready, marker::PhantomData, + sync::Arc, task::{Context, Poll}, }; use tower::{util::ServiceExt, ServiceBuilder}; @@ -1055,10 +1056,11 @@ impl Service> for Route { } } +/// Wrapper around `matchit::Node` that supports merging two `Node`s. #[derive(Clone, Default)] struct Node { inner: matchit::Node, - paths: Vec<(String, RouteId)>, + paths: Vec<(Arc, RouteId)>, } impl Node { @@ -1069,13 +1071,13 @@ impl Node { ) -> Result<(), matchit::InsertError> { let path = path.into(); self.inner.insert(&path, val)?; - self.paths.push((path, val)); + self.paths.push((path.into(), val)); Ok(()) } fn merge(&mut self, other: Node) -> Result<(), matchit::InsertError> { for (path, id) in other.paths { - self.insert(path, id)?; + self.insert(&*path, id)?; } Ok(()) }