Skip to content

Commit

Permalink
Add some macros (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
llehtahw authored Apr 1, 2024
1 parent b01fffa commit fb8378b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
42 changes: 42 additions & 0 deletions src/tuple_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,83 @@ 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) => {
$expr.into_tuple_processor().cascade_option($val)
};
}

#[macro_export]
macro_rules! cascade_option_fn {
($expr:expr) => {
|x| cascade_option!(x => $expr)
};
}

#[macro_export]
macro_rules! cascade_result {
($val:expr => $expr:expr) => {
$expr.into_tuple_processor().cascade_result($val)
};
}

#[macro_export]
macro_rules! cascade_result_fn {
($expr:expr) => {
|x| cascade_result!(x => $expr)
};
}

#[macro_export]
macro_rules! cascade_async {
($val:expr => $expr:expr) => {
$expr.into_tuple_processor().cascade_fut($val)
};
}

#[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) => {
$expr.into_tuple_processor().cascade_option_fut($val)
};
}

#[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) => {
$expr.into_tuple_processor().cascade_result_fut($val)
};
}

#[macro_export]
macro_rules! cascade_result_async_fn {
($expr:expr) => {
|x| cascade_result_async!(x => $expr)
};
}

#[cfg(test)]
mod tests {
use crate::*;
Expand Down

0 comments on commit fb8378b

Please sign in to comment.