diff --git a/actix-server/src/builder.rs b/actix-server/src/builder.rs index 7f64eed7..66f40664 100644 --- a/actix-server/src/builder.rs +++ b/actix-server/src/builder.rs @@ -325,12 +325,12 @@ impl ServerBuilder { /// (If [ServerBuilder::system_exit] is set to true) pub fn on_stop(mut self, func: F) -> Self where - F: Fn() -> Fut + Clone + 'static, - Fut: Future, + F: Fn() -> Fut + 'static, + Fut: Future + 'static, { self.on_stop = Box::new(move || { - let func = func.clone(); - Box::pin(async move { func().await }) + let fut = func(); + Box::pin(async move { fut.await }) }); self }