Crates.io | matchable |
lib.rs | matchable |
version | 0.1.1 |
source | src |
created_at | 2022-12-19 01:50:31.306594 |
updated_at | 2022-12-19 01:55:32.537288 |
description | Check if text is matching against string or regex in one API. |
homepage | |
repository | https://github.com/g-plane/matchable |
max_upload_size | |
id | 740696 |
size | 13,032 |
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.
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"));
MIT License
Copyright (c) 2022-present Pig Fang