mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 11:43:57 +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
|
||||
);
|
||||
|
||||
wrap_dialogue!(Wrapper, Dialogue);
|
||||
|
||||
impl Default for Wrapper {
|
||||
fn default() -> Self {
|
||||
Self(Dialogue::inject(StartState))
|
||||
}
|
||||
}
|
||||
wrap_dialogue!(
|
||||
Wrapper(Dialogue),
|
||||
default { Self(Dialogue::inject(StartState)) }
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// [Control a dialogue]
|
||||
|
|
|
@ -79,7 +79,7 @@ macro_rules! dispatch {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! wrap_dialogue {
|
||||
($name:ident, $dialogue:ident) => {
|
||||
($name:ident($dialogue:ident), default {$default_block:expr}) => {
|
||||
struct $name($dialogue);
|
||||
|
||||
impl teloxide::dispatching::dialogue::DialogueWrapper<$dialogue>
|
||||
|
@ -89,6 +89,12 @@ macro_rules! wrap_dialogue {
|
|||
$name(d)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for $name {
|
||||
fn default() -> $name {
|
||||
$default_block
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue