matchable

Crates.iomatchable
lib.rsmatchable
version0.1.1
sourcesrc
created_at2022-12-19 01:50:31.306594
updated_at2022-12-19 01:55:32.537288
descriptionCheck if text is matching against string or regex in one API.
homepage
repositoryhttps://github.com/g-plane/matchable
max_upload_size
id740696
size13,032
Pig Fang (g-plane)

documentation

README

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

Commit count: 6

cargo fmt