coerce_pattern

Crates.iocoerce_pattern
lib.rscoerce_pattern
version0.1.0
created_at2025-04-07 02:59:38.494061+00
updated_at2025-04-07 02:59:38.494061+00
descriptionMacros that coerce expressions into patterns, panicking on failure
homepagehttps://github.com/ktausch/coerce_pattern
repository
max_upload_size
id1623596
size14,540
Keith Tauscher (ktausch)

documentation

README

coerce_pattern

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.

  1. 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 match
  2. assert_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

Commit count: 0

cargo fmt