Function bparse::noneof

source ·
pub const fn noneof(exclusions: &str) -> NoneOf
Expand description

Inverse of oneof

§Example

use bparse::{Pattern, noneof};

let nondigits = noneof("0123456789");

assert_eq!(nondigits.test(b"A").unwrap().0, b"A");
assert_eq!(nondigits.test(b"3"), None);

This function is callable in const contexts. Additionally, the compile-time generated lookup table can be accessed from the NoneOf struct

use bparse::noneof;
const lookup: [bool; 256] = noneof("abc").0;

assert!(lookup[b'a' as usize] == false);
assert!(lookup[b'b' as usize] == false);
assert!(lookup[b'c' as usize] == false);
assert!(lookup[b'd' as usize] == true);