g-plane / matchable

`matchable` provides a convenient enum for checking if a piece of text is matching a string or a regex.

Home Page:https://docs.rs/matchable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

matchable

Crates.io docs.rs

matchable provides a convenient enum for checking if a piece of text is matching a string or a regex.

The common usage of this crate is used as configuration value type with serde feature enabled (disabled by default), then user can pass string and/or regex in just one enum. Later, you can use that enum to check if a piece of text is matching the string/regex or not.

Example

use matchable::Matchable;

assert!(Matchable::Str("Abc".into()).is_match("Abc"));
assert!(!Matchable::Str("Abc".into()).is_match("abc"));
assert!(Matchable::Regex(regex::Regex::new("abc.").unwrap()).is_match("abcd"));

License

MIT License

Copyright (c) 2022-present Pig Fang

About

`matchable` provides a convenient enum for checking if a piece of text is matching a string or a regex.

https://docs.rs/matchable/

License:MIT License


Languages

Language:Rust 100.0%