Skip to content

Commit c10934c

Browse files
authored
Relax implicit Send / Sync bounds (#3555)
1 parent 830a114 commit c10934c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

axum/src/routing/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ where
605605
/// See [`Router::as_service`] for more details.
606606
pub struct RouterAsService<'a, B, S = ()> {
607607
router: &'a mut Router<S>,
608-
_marker: PhantomData<B>,
608+
_marker: PhantomData<fn(B)>,
609609
}
610610

611611
impl<B> Service<Request<B>> for RouterAsService<'_, B, ()>
@@ -644,7 +644,7 @@ where
644644
/// See [`Router::into_service`] for more details.
645645
pub struct RouterIntoService<B, S = ()> {
646646
router: Router<S>,
647-
_marker: PhantomData<B>,
647+
_marker: PhantomData<fn(B)>,
648648
}
649649

650650
impl<B, S> Clone for RouterIntoService<B, S>
@@ -812,4 +812,8 @@ fn traits() {
812812
use crate::test_helpers::*;
813813
assert_send::<Router<()>>();
814814
assert_sync::<Router<()>>();
815+
assert_send::<RouterAsService<'static, Body, ()>>();
816+
assert_sync::<RouterAsService<'static, Body, ()>>();
817+
assert_send::<RouterIntoService<Body, ()>>();
818+
assert_sync::<RouterIntoService<Body, ()>>();
815819
}

axum/src/serve/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ where
121121
pub struct Serve<L, M, S, B> {
122122
listener: L,
123123
make_service: M,
124-
_marker: PhantomData<(S, B)>,
124+
_marker: PhantomData<fn(B) -> S>,
125125
}
126126

127127
#[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
@@ -252,7 +252,7 @@ pub struct WithGracefulShutdown<L, M, S, F, B> {
252252
listener: L,
253253
make_service: M,
254254
signal: F,
255-
_marker: PhantomData<(S, B)>,
255+
_marker: PhantomData<fn(B) -> S>,
256256
}
257257

258258
#[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]

0 commit comments

Comments
 (0)