remove clone bound for stop closure

This commit is contained in:
fakeshadow 2021-02-08 20:30:30 -08:00
parent 17a366ea5f
commit 935fcf384f
1 changed files with 4 additions and 4 deletions

View File

@ -325,12 +325,12 @@ impl ServerBuilder {
/// (If [ServerBuilder::system_exit] is set to true) /// (If [ServerBuilder::system_exit] is set to true)
pub fn on_stop<F, Fut>(mut self, func: F) -> Self pub fn on_stop<F, Fut>(mut self, func: F) -> Self
where where
F: Fn() -> Fut + Clone + 'static, F: Fn() -> Fut + 'static,
Fut: Future<Output = ()>, Fut: Future<Output = ()> + 'static,
{ {
self.on_stop = Box::new(move || { self.on_stop = Box::new(move || {
let func = func.clone(); let fut = func();
Box::pin(async move { func().await }) Box::pin(async move { fut.await })
}); });
self self
} }