pub fn prefix(slice: &[u8]) -> Prefix<'_>Expand description
Returns a new pattern that will match if slice is a prefix of the input.
use bparse::{Pattern, prefix};
let pattern = prefix(&[1]);
assert_eq!(pattern.eval(&[1, 2, 3]), Some(1));As a convenience, the Pattern trait is implemented for slices with the same effect:
use bparse::Pattern;
assert_eq!((&b"ab"[..]).eval(b"abc"), Some(2));If you are working with ascii or utf8 byte slices, consider utf8