You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assumes the closure returns Result<MatchedVars, Original>
let array = [Var1(42),Var2,Var1(10)];let filtered:Result<Vec<_>,_> = array
.iter().map(matcher!(&Var1(_0)if _0 > 20)).collect();// `Var2` is the first value that doesn't matchassert_eq!(filtered,Err(&Var2));
The text was updated successfully, but these errors were encountered:
Change of plan: Insta-stabilized the feature in commit 7e3beed. Since it's not an ecosystem kind of crate, we can just increase the major version anytime without causing an ecosystem split.
A new macro that acts like a curried function (e.g.,
matcher!($pat)($expr) == try_match!($expr, $pat)
) could be useful in some situations.Issues
matcher!($pat)
try_matcher!($pat)
try_match!(_, $pat)
,try_match!(, $pat)
,try_match!($pat)
Option<MatchedVars>
orResult<MatchedVars, Original>
?Option<_>
#8if
guard and the success expression (=> $expr
) capture outer variables bymove
?Examples
Iterator::filter_map
Assumes the closure returns
Option<MatchedVars>
Assumes the closure returns
Result<MatchedVars, Original>
Applicable use cases in the wild:
Tamschi/quote-miner
,yvt/Stella2
Iterator::map
+ FallibleIterator::collect
Assumes the closure returns
Result<MatchedVars, Original>
The text was updated successfully, but these errors were encountered: