1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! A convenience macro for writing pattern-matching tests in the Rust programming language.
//!
//! The `assert_let` macro tests whether a value matches a given pattern, binding the pattern in the current scope if the match succeeds and causing a panic if the match //! fails.
//!
//! (Strongly inspired by [assert_matches](https://github.com/murarth/assert_matches))
//!
//! ```rust
//! # #![allow(unstable_features)]
//! # #![feature(let_else)]
//! use assert_let_bind::assert_let;
//!
//! #[derive(Debug)]
//! enum Foo {
//! A(i32, i32),
//! B(i32),
//! }
//!
//! let foo = Foo::A(3000, 2000);
//!
//! assert_let!(Foo::A(x, y), foo);
//! assert_eq!(x + y, 5000);
//! ```
/// Asserts that a pattern matches a given expression.
///
/// Generally speaking, `assert_let(pattern, expr)` is roughly equivalent to:
///
/// ```rust
/// # #![allow(unstable_features)]
/// # #![feature(let_else)]
/// # #[cfg(FALSE)]
/// let pattern = expr else { panic!("some panic message with {} {}", pattern, expr)};
/// ```