- Rust 100%
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
match-utils
Macros for more involved pattern matching than the standard library allows.
Examples
You can create a matcher for multiple regex patterns using the regex_match! macro. It can handle pure matching, as
well as using a fixed number of unnamed capture groups. For example:
let a = "some string to match";
regex_match! (a, {
"^some" => println!("Starts with some!"),
"add *(-?[0-9]+), *(-?[0-9]+)" [lhs: i32, rhs: i32] => {
println!("Sum: {}", lval + rval);
},
_ => println!("Default case")
});
Type arguments can be provided, assuming that they implement the FromStr trait.
License
This library is licensed under The Apache License, version 2.0.
Copyright 2025 Dustin Thomas io@cptlobster.dev
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.