From 9feb526c036a62647fa61e964319b1f84b9cf430 Mon Sep 17 00:00:00 2001 From: novacrazy Date: Wed, 9 Oct 2024 23:31:00 +0200 Subject: [PATCH] remove one clone --- axum/src/routing/mod.rs | 8 ++++---- axum/src/routing/tests/fallback.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 54dfbc77..ff43a56c 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -668,12 +668,12 @@ where } } - fn call_with_state(&mut self, req: Request, state: S) -> RouteFuture { + fn call_with_state(self, req: Request, state: S) -> RouteFuture { match self { - Fallback::Default(route) | Fallback::Service(route) => route.oneshot_inner(req), + Fallback::Default(route) | Fallback::Service(route) => route.oneshot_inner_owned(req), Fallback::BoxedHandler(handler) => { - let mut route = handler.clone().into_route(state); - route.oneshot_inner(req) + let route = handler.clone().into_route(state); + route.oneshot_inner_owned(req) } } } diff --git a/axum/src/routing/tests/fallback.rs b/axum/src/routing/tests/fallback.rs index 4ff55ae4..02850b19 100644 --- a/axum/src/routing/tests/fallback.rs +++ b/axum/src/routing/tests/fallback.rs @@ -344,5 +344,5 @@ async fn state_isnt_cloned_too_much_with_fallback() { client.get("/does-not-exist").await; - assert_eq!(state.count(), 4); + assert_eq!(state.count(), 3); }