30 lines
823 B
Rust
30 lines
823 B
Rust
#[macro_export]
|
|
macro_rules! impl_from_enum {
|
|
($source:ty, $target:ty, $( $variant:ident ),* ) => {
|
|
impl From<$source> for $target {
|
|
fn from(item: $source) -> Self {
|
|
match item {
|
|
$( <$source>::$variant => <$target>::$variant, )*
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<$target> for $source {
|
|
fn from(item: $target) -> Self {
|
|
match item {
|
|
$( <$target>::$variant => <$source>::$variant, )*
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! create_send_await {
|
|
($sender:expr, $action:expr, $($contents:expr),*) => {
|
|
let (message, receiver) = $action($($contents),*);
|
|
$sender.send(message).await.unwrap();
|
|
receiver.await.unwrap()
|
|
};
|
|
}
|