coerce_pattern 0.1.0

Macros that coerce expressions into patterns, panicking on failure
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 14.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 313.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ktausch

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