1
0
Fork 0
mirror of https://github.com/tokio-rs/axum.git synced 2025-04-26 13:56:22 +02:00

Drop Sync requirement on the handler function ()

Since it doesn't need to be called from different threads at the same
time.
This commit is contained in:
david-perez 2021-11-16 15:00:56 +01:00 committed by GitHub
parent e2e9f1ff68
commit 3cf8ee3b5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions
axum-debug/src
axum/src/handler

View file

@ -346,7 +346,7 @@ mod debug {
fn debug_handler<F, Fut, #(#generics),*>(_f: F)
where
F: ::std::ops::FnOnce(#(#generics),*) -> Fut + Clone + Send + Sync + 'static,
F: ::std::ops::FnOnce(#(#generics),*) -> Fut + Clone + Send + 'static,
Fut: ::std::future::Future + Send,
{}
}

View file

@ -41,7 +41,7 @@
//! - Are `async fn`s.
//! - Take no more than 16 arguments that all implement [`FromRequest`].
//! - Returns something that implements [`IntoResponse`].
//! - If a closure is used it must implement `Clone + Send + Sync` and be
//! - If a closure is used it must implement `Clone + Send` and be
//! `'static`.
//! - Returns a future that is `Send`. The most common way to accidentally make a
//! future `!Send` is to hold a `!Send` type across an await.
@ -264,7 +264,7 @@ pub trait Handler<B, T>: Clone + Send + Sized + 'static {
#[async_trait]
impl<F, Fut, Res, B> Handler<B, ()> for F
where
F: FnOnce() -> Fut + Clone + Send + Sync + 'static,
F: FnOnce() -> Fut + Clone + Send + 'static,
Fut: Future<Output = Res> + Send,
Res: IntoResponse,
B: Send + 'static,
@ -282,7 +282,7 @@ macro_rules! impl_handler {
#[allow(non_snake_case)]
impl<F, Fut, B, Res, $($ty,)*> Handler<B, ($($ty,)*)> for F
where
F: FnOnce($($ty,)*) -> Fut + Clone + Send + Sync + 'static,
F: FnOnce($($ty,)*) -> Fut + Clone + Send + 'static,
Fut: Future<Output = Res> + Send,
B: Send + 'static,
Res: IntoResponse,