mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-21 14:29:01 +01:00
Improve wrap_dialogue!
This commit is contained in:
parent
6ff1800f12
commit
01dc7a0d42
2 changed files with 11 additions and 8 deletions
|
@ -98,13 +98,10 @@ type Dialogue = Coprod!(
|
||||||
ReceiveFavouriteMusicState
|
ReceiveFavouriteMusicState
|
||||||
);
|
);
|
||||||
|
|
||||||
wrap_dialogue!(Wrapper, Dialogue);
|
wrap_dialogue!(
|
||||||
|
Wrapper(Dialogue),
|
||||||
impl Default for Wrapper {
|
default { Self(Dialogue::inject(StartState)) }
|
||||||
fn default() -> Self {
|
);
|
||||||
Self(Dialogue::inject(StartState))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// [Control a dialogue]
|
// [Control a dialogue]
|
||||||
|
|
|
@ -79,7 +79,7 @@ macro_rules! dispatch {
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! wrap_dialogue {
|
macro_rules! wrap_dialogue {
|
||||||
($name:ident, $dialogue:ident) => {
|
($name:ident($dialogue:ident), default {$default_block:expr}) => {
|
||||||
struct $name($dialogue);
|
struct $name($dialogue);
|
||||||
|
|
||||||
impl teloxide::dispatching::dialogue::DialogueWrapper<$dialogue>
|
impl teloxide::dispatching::dialogue::DialogueWrapper<$dialogue>
|
||||||
|
@ -89,6 +89,12 @@ macro_rules! wrap_dialogue {
|
||||||
$name(d)
|
$name(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for $name {
|
||||||
|
fn default() -> $name {
|
||||||
|
$default_block
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue