From b3b377d467ef4f8ca49be876f8bf7a9cc8880410 Mon Sep 17 00:00:00 2001
From: David Pedersen <david.pdrsn@gmail.com>
Date: Sat, 6 Nov 2021 14:06:20 +0100
Subject: [PATCH] Implement `Clone` for `IntoMakeServiceWithConnectInfo` (#471)

Fixes https://github.com/tokio-rs/axum/issues/470
---
 axum/CHANGELOG.md                |  4 +++-
 axum/src/extract/connect_info.rs | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md
index 11e01202..f1c0f092 100644
--- a/axum/CHANGELOG.md
+++ b/axum/CHANGELOG.md
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 # Unreleased
 
-- None
+- **fixed:** Implement `Clone` for `IntoMakeServiceWithConnectInfo` ([#471])
+
+[#471]: https://github.com/tokio-rs/axum/pull/471
 
 # 0.3.0 (02. November, 2021)
 
diff --git a/axum/src/extract/connect_info.rs b/axum/src/extract/connect_info.rs
index 9fcd18e0..11a8fb75 100644
--- a/axum/src/extract/connect_info.rs
+++ b/axum/src/extract/connect_info.rs
@@ -56,6 +56,18 @@ where
     }
 }
 
+impl<S, C> Clone for IntoMakeServiceWithConnectInfo<S, C>
+where
+    S: Clone,
+{
+    fn clone(&self) -> Self {
+        Self {
+            svc: self.svc.clone(),
+            _connect_info: PhantomData,
+        }
+    }
+}
+
 /// Trait that connected IO resources implement and use to produce information
 /// about the connection.
 ///