mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Drop Sync requirement on the handler function (#522)
Since it doesn't need to be called from different threads at the same time.
This commit is contained in:
@@ -346,7 +346,7 @@ mod debug {
|
|||||||
|
|
||||||
fn debug_handler<F, Fut, #(#generics),*>(_f: F)
|
fn debug_handler<F, Fut, #(#generics),*>(_f: F)
|
||||||
where
|
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,
|
Fut: ::std::future::Future + Send,
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
//! - Are `async fn`s.
|
//! - Are `async fn`s.
|
||||||
//! - Take no more than 16 arguments that all implement [`FromRequest`].
|
//! - Take no more than 16 arguments that all implement [`FromRequest`].
|
||||||
//! - Returns something that implements [`IntoResponse`].
|
//! - 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`.
|
//! `'static`.
|
||||||
//! - Returns a future that is `Send`. The most common way to accidentally make a
|
//! - 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.
|
//! 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]
|
#[async_trait]
|
||||||
impl<F, Fut, Res, B> Handler<B, ()> for F
|
impl<F, Fut, Res, B> Handler<B, ()> for F
|
||||||
where
|
where
|
||||||
F: FnOnce() -> Fut + Clone + Send + Sync + 'static,
|
F: FnOnce() -> Fut + Clone + Send + 'static,
|
||||||
Fut: Future<Output = Res> + Send,
|
Fut: Future<Output = Res> + Send,
|
||||||
Res: IntoResponse,
|
Res: IntoResponse,
|
||||||
B: Send + 'static,
|
B: Send + 'static,
|
||||||
@@ -282,7 +282,7 @@ macro_rules! impl_handler {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl<F, Fut, B, Res, $($ty,)*> Handler<B, ($($ty,)*)> for F
|
impl<F, Fut, B, Res, $($ty,)*> Handler<B, ($($ty,)*)> for F
|
||||||
where
|
where
|
||||||
F: FnOnce($($ty,)*) -> Fut + Clone + Send + Sync + 'static,
|
F: FnOnce($($ty,)*) -> Fut + Clone + Send + 'static,
|
||||||
Fut: Future<Output = Res> + Send,
|
Fut: Future<Output = Res> + Send,
|
||||||
B: Send + 'static,
|
B: Send + 'static,
|
||||||
Res: IntoResponse,
|
Res: IntoResponse,
|
||||||
|
|||||||
Reference in New Issue
Block a user