pub const fn not<P: Pattern>(pattern: P) -> Not<P>Expand description
Expresses pattern negation
Returns a new pattern that will match only if pattern does not match
Note: This is a peek-like operation. It will always return Some((&[], _)) (i.e. an empty
slice) in the successful case. It does not advance Parser. It is useful for “negative
lookahead”
§Example
Say you want to match a string of multiple ’a’s and ’b’s, except the string must not end in a ‘b’:
use bparse::{Pattern, not, end};
let input1 = b"aabaaaa";
let input2 = b"aaaab";
// a pattern of either a's or b's that do not occur at the input
let pattern = "a".or("b".and(not(end))).repeats(0..);
assert_eq!(b"aabaaaa", pattern.test(input1).unwrap().0);
assert_eq!(b"aaaa", pattern.test(input2).unwrap().0);§Example
use bparse::{Pattern, not};
let input = b"b";
let pattern = not("a");
assert!(matches!(pattern.test(input), Some((&[], _))));