rust/library/core
Mara 04045cc83f
Rollup merge of #82770 - m-ou-se:assert-match, r=joshtriplett
Add assert_matches macro.

This adds `assert_matches!(expression, pattern)`.

Unlike the other asserts, this one ~~consumes the expression~~ may consume the expression, to be able to match the pattern. (It could add a `&` implicitly, but that's noticable in the pattern, and will make a consuming guard impossible.)

See https://github.com/rust-lang/rust/issues/62633#issuecomment-790737853

This re-uses the same `left: .. right: ..` output as the `assert_eq` and `assert_ne` macros, but with the pattern as the right part:

assert_eq:
```
assertion failed: `(left == right)`
  left: `Some("asdf")`,
 right: `None`
```
assert_matches:
```
assertion failed: `(left matches right)`
  left: `Ok("asdf")`,
 right: `Err(_)`
```

cc ```@cuviper```
2021-03-05 10:57:23 +01:00
..
benches Unify way to flip 6th bit. (Same assembly generated) 2021-02-08 12:21:36 +00:00
src Rollup merge of #82770 - m-ou-se:assert-match, r=joshtriplett 2021-03-05 10:57:23 +01:00
tests Rollup merge of #82289 - SkiFire13:fix-issue-82282, r=m-ou-se 2021-03-05 10:57:19 +01:00
Cargo.toml mv std libs to library/ 2020-07-27 19:51:13 -05:00