mirror of https://github.com/fafhrd91/actix-net
use FnOnce instead of Fn
This commit is contained in:
parent
6012bcf941
commit
54e8b6628c
|
@ -299,7 +299,7 @@ impl ServerBuilder {
|
|||
|
||||
pub fn on_stop<F, Fut>(mut self, future: F) -> Self
|
||||
where
|
||||
F: Fn() -> Fut + 'static,
|
||||
F: FnOnce() -> Fut + 'static,
|
||||
Fut: Future<Output = ()>,
|
||||
{
|
||||
self.on_stop = Box::pin(async move { future().await });
|
||||
|
|
|
@ -201,11 +201,8 @@ fn test_on_stop() {
|
|||
let srv: Server = Server::build()
|
||||
.backlog(100)
|
||||
.disable_signals()
|
||||
.on_stop(move || {
|
||||
let bool = bool.clone();
|
||||
async move {
|
||||
bool.store(true, Ordering::SeqCst);
|
||||
}
|
||||
.on_stop(|| async move {
|
||||
bool.store(true, Ordering::SeqCst);
|
||||
})
|
||||
.bind("test", addr, move || {
|
||||
fn_service(|io: TcpStream| async move {
|
||||
|
|
Loading…
Reference in New Issue