| Crates.io | coerce_pattern |
| lib.rs | coerce_pattern |
| version | 0.1.0 |
| created_at | 2025-04-07 02:59:38.494061+00 |
| updated_at | 2025-04-07 02:59:38.494061+00 |
| description | Macros that coerce expressions into patterns, panicking on failure |
| homepage | https://github.com/ktausch/coerce_pattern |
| repository | |
| max_upload_size | |
| id | 1623596 |
| size | 14,540 |
coerce_pattern is a Rust library crate containing macros that force expressions into patterns. It is version-controlled on GitHub here.
This crate contains two proc macros relating to asserting, under penalty of panic, that expressions match patterns.
coerce_pattern! matches an expression to a target pattern and evaluates to an expression of the inner variables from the pattern, panicking if the pattern doesn't matchassert_pattern! matches an expression to a target and panics if the pattern doesn't match.To use them, run the following command in your project directory.
cargo add coerce_pattern
Then, you can use the macros using
use coerce_pattern::{coerce_pattern, assert_pattern};
See the documentation in src/lib.rs for more details