diff --git a/examples/heroku_ping_pong_bot/src/main.rs b/examples/heroku_ping_pong_bot/src/main.rs index ddb7769f..2043ec49 100644 --- a/examples/heroku_ping_pong_bot/src/main.rs +++ b/examples/heroku_ping_pong_bot/src/main.rs @@ -62,7 +62,7 @@ pub async fn webhook(bot: AutoSend) -> impl update_listeners::UpdateListene fn streamf(state: &mut (S, T)) -> &mut S { &mut state.0 } - StatefulListener::new((stream, stop_token), streamf, |state: &mut (_, AsyncStopToken)| state.1.clone(), None:: fn(&'a _) -> _>) + StatefulListener::new((stream, stop_token), streamf, |state: &mut (_, AsyncStopToken)| state.1.clone()) } async fn run() { diff --git a/examples/ngrok_ping_pong_bot/src/main.rs b/examples/ngrok_ping_pong_bot/src/main.rs index 8863eb8f..8a35d5ad 100644 --- a/examples/ngrok_ping_pong_bot/src/main.rs +++ b/examples/ngrok_ping_pong_bot/src/main.rs @@ -54,7 +54,7 @@ pub async fn webhook(bot: AutoSend) -> impl update_listeners::UpdateListene fn streamf(state: &mut (S, T)) -> &mut S { &mut state.0 } - StatefulListener::new((stream, stop_token), streamf, |state: &mut (_, AsyncStopToken)| state.1.clone(), None:: fn(&'a _) -> _>) + StatefulListener::new((stream, stop_token), streamf, |state: &mut (_, AsyncStopToken)| state.1.clone()) } async fn run() { diff --git a/src/dispatching/update_listeners/stateful_listener.rs b/src/dispatching/update_listeners/stateful_listener.rs index 9150daef..b7a243c6 100644 --- a/src/dispatching/update_listeners/stateful_listener.rs +++ b/src/dispatching/update_listeners/stateful_listener.rs @@ -39,9 +39,21 @@ pub struct StatefulListener { pub timeout_hint: Option, } +impl StatefulListener fn(&'a St) -> Option> { + /// Creates new stateful listener from it's components. + pub fn new(state: St, stream: Assf, stop_token: Sf) -> Self { + Self { state, stream, stop_token, timeout_hint: None } + } +} + impl StatefulListener { /// Creates new stateful listener from it's components. - pub fn new(state: St, stream: Assf, stop_token: Sf, timeout_hint: Option) -> Self { + pub fn new_with_timeout_hint( + state: St, + stream: Assf, + stop_token: Sf, + timeout_hint: Option, + ) -> Self { Self { state, stream, stop_token, timeout_hint } } }