Converts the pattern part of the match
expression into a &'static str
.
It is mainly intended to be used when you want to convert a variable name into a string as is.
$ cargo add match_to_str
```rust use matchtostr::matchtostr;
const CAT: u8 = 1; const DOG: u8 = 2;
fn main() { let animal = matchtostr!(1 => { CAT, DOG, , }); asserteq!(animal, "CAT"); } ```
expand to:
rust
let animal = match 1 {
CAT => "CAT",
DOG => "DOG",
_ => "_",
};
This project welcomes your PR and issues. For example, fixing bugs, adding features, refactoring, etc.