Function bparse::byteset

source ·
pub fn byteset(alternatives: &str) -> ByteSet
Expand description

Returns a pattern that will match any one of the bytes in alternatives

This is a useful alternative to a long Pattern::or() chain when you have many single-byte alternatives.

Example

use bparse::{Pattern, byteset};

let punctuation = byteset(".,\"'-?:!;");
assert_eq!(punctuation.test(b"!").unwrap().value(), b"!");
assert_eq!(punctuation.test(b",").unwrap().value(), b",");
assert_eq!(punctuation.test(b"a"), None);