Enhance the v0.11 migration guide

Former-commit-id: c4dbff1afe
This commit is contained in:
Hirrolot 2022-10-04 09:56:51 +06:00 committed by GitHub
parent 3efa74c8f2
commit c5585eed14

View file

@ -6,7 +6,17 @@ Note that the list of required changes is not fully exhaustive and it may lack s
### core
Requests can now be `.await`ed directly, without need of `.send()` or `AutoSend`.
If you previously used `AutoSend` adaptor, you can safely remove it.
If you previously used `AutoSend` adaptor, you can safely remove it:
```diff,rust
-let bot = Bot::from_env().auto_send();
+let bot = Bot::from_env();
```
```diff,rust
-async fn start(bot: AutoSend<Bot>, dialogue: MyDialogue, msg: Message) -> HandlerResult {
+async fn start(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
```
`File`'s and `FileMeta`'s fields now don't have `file_` prefix.
If you previously accessed the fields, you'll need to change remove the prefix:
@ -52,7 +62,18 @@ See `Sticker` documentation for more information about the new structure.
### teloxide
<!-- TODO -->
You can now write `Ok(())` instead of `respond(())` at the end of closures provided to RELPs:
```diff,rust
teloxide::repl(bot, |bot: Bot, msg: Message| async move {
bot.send_dice(msg.chat.id).await?;
- respond(())
+ Ok(())
})
.await;
```
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.
## 0.9 -> 0.10