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
|
pub fn on_stop<F, Fut>(mut self, future: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn() -> Fut + 'static,
|
F: FnOnce() -> Fut + 'static,
|
||||||
Fut: Future<Output = ()>,
|
Fut: Future<Output = ()>,
|
||||||
{
|
{
|
||||||
self.on_stop = Box::pin(async move { future().await });
|
self.on_stop = Box::pin(async move { future().await });
|
||||||
|
|
|
@ -201,11 +201,8 @@ fn test_on_stop() {
|
||||||
let srv: Server = Server::build()
|
let srv: Server = Server::build()
|
||||||
.backlog(100)
|
.backlog(100)
|
||||||
.disable_signals()
|
.disable_signals()
|
||||||
.on_stop(move || {
|
.on_stop(|| async move {
|
||||||
let bool = bool.clone();
|
bool.store(true, Ordering::SeqCst);
|
||||||
async move {
|
|
||||||
bool.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.bind("test", addr, move || {
|
.bind("test", addr, move || {
|
||||||
fn_service(|io: TcpStream| async move {
|
fn_service(|io: TcpStream| async move {
|
||||||
|
|
Loading…
Reference in New Issue