Browse Source

Initial commit

master v1.0.0
Michael Pfaff 6 months ago
commit
61e2e31970
Signed by: michael GPG Key ID: E53B118B12B5C7F9
  1. 2
      .gitignore
  2. 8
      Cargo.toml
  3. 4
      README.md
  4. 13
      src/lib.rs

2
.gitignore

@ -0,0 +1,2 @@
/target
Cargo.lock

8
Cargo.toml

@ -0,0 +1,8 @@
[package]
name = "duplicative_match"
version = "1.0.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

4
README.md

@ -0,0 +1,4 @@
# duplicative_match.rs
A macro that duplicates the provided transformer for all match cases. Useful when types are conflicting but the transformer would work on all of them.

13
src/lib.rs

@ -0,0 +1,13 @@
/// Duplicates the provided transformer for all match cases. Useful when types are conflicting but the transformer would work on all of them.
#[macro_export]
macro_rules! duplicative_match {
(($subject:expr) { $($pat:pat => $result:expr),+ }, $transformed:ident => $transformer:expr) => {
match $subject {
$($pat => {
let $transformed = $result;
$transformer
}),+
}
};
}
Loading…
Cancel
Save