Function bparse::oneof

source ·
pub fn oneof(alternatives: &str) -> OneOf
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, oneof};

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