Update README.md

This commit is contained in:
Temirkhan Myrzamadi 2020-07-24 19:46:13 +06:00
parent 7e4014260a
commit 1a343e377f

View file

@ -237,17 +237,16 @@ The handy `up!` macro automatically generates functions that complete one state
```rust
// Imports are omitted...
pub type Cx = UpdateWithCx<Message>;
pub type Out = TransitionOut<Dialogue>;
pub async fn start(cx: Cx, state: StartState) -> Out {
pub async fn start(cx: TransitionIn, state: StartState) -> Out {
cx.answer_str("Let's start our test! How many days per week are there?")
.await?;
next(state.up())
}
pub async fn receive_days_of_week(
cx: Cx,
cx: TransitionIn,
state: ReceiveDaysOfWeekState,
) -> Out {
match cx.update.text().map(str::parse) {
@ -262,7 +261,10 @@ pub async fn receive_days_of_week(
}
}
pub async fn receive_10x5_answer(cx: Cx, state: Receive10x5AnswerState) -> Out {
pub async fn receive_10x5_answer(
cx: TransitionIn,
state: Receive10x5AnswerState,
) -> Out {
match cx.update.text().map(str::parse) {
Some(Ok(ans)) if ans == 50 => {
cx.answer_str("What's an alternative name of Gandalf?").await?;
@ -276,7 +278,7 @@ pub async fn receive_10x5_answer(cx: Cx, state: Receive10x5AnswerState) -> Out {
}
pub async fn receive_gandalf_alternative_name(
cx: Cx,
cx: TransitionIn,
state: ReceiveGandalfAlternativeNameState,
) -> Out {
match cx.update.text() {
@ -308,7 +310,7 @@ async fn main() {
Dispatcher::new(bot)
.messages_handler(DialogueDispatcher::new(
|input: TransitionIn<Dialogue, Infallible>| async move {
|input: DialogueWithCx<Message, Dialogue, Infallible>| async move {
// Unwrap without panic because of std::convert::Infallible.
input
.dialogue