Relax implicit Send / Sync bounds (#3555)

This commit is contained in:
Jonas Platte
2025-11-14 10:48:07 +01:00
committed by GitHub
parent 830a114172
commit c10934c79c
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -605,7 +605,7 @@ where
/// See [`Router::as_service`] for more details.
pub struct RouterAsService<'a, B, S = ()> {
router: &'a mut Router<S>,
_marker: PhantomData<B>,
_marker: PhantomData<fn(B)>,
}
impl<B> Service<Request<B>> for RouterAsService<'_, B, ()>
@@ -644,7 +644,7 @@ where
/// See [`Router::into_service`] for more details.
pub struct RouterIntoService<B, S = ()> {
router: Router<S>,
_marker: PhantomData<B>,
_marker: PhantomData<fn(B)>,
}
impl<B, S> Clone for RouterIntoService<B, S>
@@ -812,4 +812,8 @@ fn traits() {
use crate::test_helpers::*;
assert_send::<Router<()>>();
assert_sync::<Router<()>>();
assert_send::<RouterAsService<'static, Body, ()>>();
assert_sync::<RouterAsService<'static, Body, ()>>();
assert_send::<RouterIntoService<Body, ()>>();
assert_sync::<RouterIntoService<Body, ()>>();
}
+2 -2
View File
@@ -121,7 +121,7 @@ where
pub struct Serve<L, M, S, B> {
listener: L,
make_service: M,
_marker: PhantomData<(S, B)>,
_marker: PhantomData<fn(B) -> S>,
}
#[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
@@ -252,7 +252,7 @@ pub struct WithGracefulShutdown<L, M, S, F, B> {
listener: L,
make_service: M,
signal: F,
_marker: PhantomData<(S, B)>,
_marker: PhantomData<fn(B) -> S>,
}
#[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]