Releases: yvt/try_match-rs
0.4.2
0.4.1
-
(inner 0.5.1) Fix field shorthands in struct patterns causing a syntax error
error: expected `,` --> tests/test.rs:201:16 | 201 | assert_eq!(match_ok!(A { x: 42 }, A { x }), Some(42)); | ^^^^^^^^^^^^^^^^^^^^^^^-^^^^^^^ | | | while parsing the fields for this pattern
-
Fix struct expressions causing a syntax error when used as a scrutinee expression
error: struct literals are not allowed here --> tests/test.rs:181:26 | 181 | assert_eq!(match_ok!(A { x: 42 }, A { x }), Some(42)); | ^^^^^^^^^^^
0.4.0
-
Breaking: Use heuristics based on the standard naming conventions to distinguish constant patterns from variable bindings (#6)
let _: Result<i32, i32> = try_match!(42, zero); // binding const ZERO: i32 = 0; let _: Result<(), i32> = try_match!(42, ZERO); // constant pattern
-
Support partial application (#3)
let _: Result<i32, _> = try_match!(Var1(42), Var1(x)); let _: fn(Enum<i32>) -> Result<i32, _> = try_match!( , Var1(x));
-
Add a new macro
match_ok!
that returnsOption
instead ofResult
(#8)let array = [Var1(42), Var2, Var1(10)]; let filtered: Vec<_> = array .iter() .filter_map(match_ok!(, &Var1(_0) if _0 > 20)) .collect(); assert_eq!(filtered, [42]);
-
Add a new macro
unwrap_match!
that panics on failure (#5)assert_eq!(unwrap_match!(Var1(42), Var1(x) if x > 20, "oops"), 42);
-
Suppress
clippy::just_underscores_and_digits
in implicit tuple mapping (#2) -
Handle parentheses and inline
const
patterns (#7) -
Allow trailing commas in macro invocations (#9)
-
Increase MSRV to 1.56.0
0.3.0
-
Breaking: Change the syntax to be compatible with
core::matches!
and other similar macrosassert_eq!(try_match!(Var1(x) = Var1(42)), Ok(42)); // old assert_eq!(try_match!(Var1(42), Var1(x)), Ok(42)); // new
-
Support
if
guardsassert_eq!(try_match!(Var1(42), Var1(x) if x < 20), Err(Var1(42)));
-
Remove
std
from the default Cargo feature set -
Remove
proc-macro-hack
dependency -
Increase MSRV to 1.45