Further compile time improvements (#220)

This improves compiles further when using lots of nested routes. Such as
the example posted
[here](https://github.com/tokio-rs/axum/issues/200#issuecomment-902541073).

It seems rustc is really slow at checking bounds on these kinds of
intermediate builder methods. Should probably file an issue about that.
This commit is contained in:
David Pedersen
2021-08-20 19:51:29 +02:00
committed by GitHub
parent be61b8c611
commit e8bc3f5082
2 changed files with 15 additions and 19 deletions
+2 -8
View File
@@ -119,10 +119,7 @@ impl<S> Router<S> {
/// # Panics
///
/// Panics if `description` doesn't start with `/`.
pub fn route<T, B>(self, description: &str, svc: T) -> Router<Route<T, S>>
where
T: Service<Request<B>> + Clone,
{
pub fn route<T>(self, description: &str, svc: T) -> Router<Route<T, S>> {
self.map(|fallback| Route {
pattern: PathPattern::new(description),
svc,
@@ -207,10 +204,7 @@ impl<S> Router<S> {
/// If necessary you can use [`Router::boxed`] to box a group of routes
/// making the type easier to name. This is sometimes useful when working with
/// `nest`.
pub fn nest<T, B>(self, description: &str, svc: T) -> Router<Nested<T, S>>
where
T: Service<Request<B>> + Clone,
{
pub fn nest<T>(self, description: &str, svc: T) -> Router<Nested<T, S>> {
self.map(|fallback| Nested {
pattern: PathPattern::new(description),
svc,