const-regex

Crates.ioconst-regex
lib.rsconst-regex
version0.1.0
sourcesrc
created_at2021-04-18 20:20:00.678125
updated_at2021-04-18 20:20:00.678125
descriptionMatch regexes inside a const fn
homepage
repositoryhttps://github.com/leo60228/const-regex
max_upload_size
id386336
size10,135
leo60228 (leo60228)

documentation

README

const-regex

Proc macro to match regexes in const fns. The regex must be a string literal, but the bytes matched can be any value.

The macro expects an &[u8], but you can easily use str::as_bytes.

const fn this_crate(bytes: &[u8]) -> bool {
    const_regex::match_regex!("^(meta-)*regex matching", bytes)
}

assert!(this_crate(b"meta-meta-regex matching"));
assert!(!this_crate(b"a good idea"));
Commit count: 4

cargo fmt