From fb8378be66c09a0130ca1d6678f531f5290926dd Mon Sep 17 00:00:00 2001 From: llehtahw Date: Mon, 1 Apr 2024 11:01:26 +0800 Subject: [PATCH] Add some macros (#8) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/tuple_proc.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8f8ebf..8b80fc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,7 +267,7 @@ dependencies = [ [[package]] name = "statecs" -version = "0.2.0" +version = "0.3.1" dependencies = [ "procs", "tokio", diff --git a/Cargo.toml b/Cargo.toml index c17eb42..a93d108 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ workspace = { members = ["procs"] } [package] name = "statecs" -version = "0.3.0" +version = "0.3.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/tuple_proc.rs b/src/tuple_proc.rs index a41e9e7..0b5f88d 100644 --- a/src/tuple_proc.rs +++ b/src/tuple_proc.rs @@ -21,6 +21,13 @@ macro_rules! cascade { }; } +#[macro_export] +macro_rules! cascade_fn { + ($expr:expr) => { + |x| cascade!(x => $expr) + }; +} + #[macro_export] macro_rules! cascade_option { ($val:expr => $expr:expr) => { @@ -28,6 +35,13 @@ macro_rules! cascade_option { }; } +#[macro_export] +macro_rules! cascade_option_fn { + ($expr:expr) => { + |x| cascade_option!(x => $expr) + }; +} + #[macro_export] macro_rules! cascade_result { ($val:expr => $expr:expr) => { @@ -35,6 +49,13 @@ macro_rules! cascade_result { }; } +#[macro_export] +macro_rules! cascade_result_fn { + ($expr:expr) => { + |x| cascade_result!(x => $expr) + }; +} + #[macro_export] macro_rules! cascade_async { ($val:expr => $expr:expr) => { @@ -42,6 +63,13 @@ macro_rules! cascade_async { }; } +#[macro_export] +macro_rules! cascade_async_fn { + ($expr:expr) => { + |x| cascade_async!(x => $expr) + }; +} + #[macro_export] macro_rules! cascade_option_async { ($val:expr => $expr:expr) => { @@ -49,6 +77,13 @@ macro_rules! cascade_option_async { }; } +#[macro_export] +macro_rules! cascade_option_async_fn { + ($expr:expr) => { + |x| cascade_option_async!(x => $expr) + }; +} + #[macro_export] macro_rules! cascade_result_async { ($val:expr => $expr:expr) => { @@ -56,6 +91,13 @@ macro_rules! cascade_result_async { }; } +#[macro_export] +macro_rules! cascade_result_async_fn { + ($expr:expr) => { + |x| cascade_result_async!(x => $expr) + }; +} + #[cfg(test)] mod tests { use crate::*;