Skip to content

Commit

Permalink
Fix cascade_fn! (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
llehtahw committed Apr 17, 2024
1 parent 7a4a78d commit 25ecaa9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 40 deletions.
73 changes: 40 additions & 33 deletions 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.2"
version = "0.3.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! chain {
|x| {$first(x)}
};
[$first:expr, $($exprs:expr),* $(,)?] => {
|x| {(chain![$($exprs),*])($first(x))}
|x| { let x = $first(x); $(let x = $exprs(x);)* x}
};
}

Expand Down
17 changes: 12 additions & 5 deletions src/tuple_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ pub trait IntoTupleProcessor<IType, OType, _M> {

#[macro_export]
macro_rules! cascade {
($val:expr => $expr:expr) => {
($val:expr => $expr:expr) => {{
use $crate::IntoTupleProcessor;
$expr.into_tuple_processor().cascade($val)
};
}};
}

#[macro_export]
macro_rules! cascade_fn {
(ref $expr:expr) => {
|x| cascade!(x => $expr)
(once $expr:expr) => {
{
let __e = $expr;
move |x| { $crate::cascade!(x => __e) }
}
};
($expr:expr) => {
move |x| cascade!(x => $expr)
{
let mut __e = $expr;
move |x| { $crate::cascade!(x => &mut __e) }
}
};
}

Expand Down

0 comments on commit 25ecaa9

Please sign in to comment.