Add stop token changes to the migration guide

Former-commit-id: 7287ffe2f0
This commit is contained in:
Maybe Waffle 2022-10-31 13:44:32 +04:00
parent e094d6a20a
commit 3ecb3fb06a

View file

@ -91,6 +91,16 @@ teloxide::repl(bot, |bot: Bot, msg: Message| async move {
This is because REPLs now require the closure to return `RequestError` instead of a generic error type, so type inference works perfectly for a return value. If you use something other than `RequestError`, you can transfer your code to `teloxide::dispatching`, which still permits a generic error type.
"Stop tokens" were refactored, the trait is now removed and the types were renamed:
```diff
-use teloxide::dispatching::stop_token::{AsyncStopToken, AsyncStopFlag};
+use teloxide::stop::{StopToken, StopFlag, mk_stop_token};
-let (token, flag): (AsyncStopToken, AsyncStopFlag) = AsyncStopToken::new_pair();
+let (token, flag): (StopToken, StopFlag) = mk_stop_token();
```
### macros
`parse_with` now accepts a Rust _path_ to a custom parser function instead of a string: