pub fn prefix<T>(slice: &[T]) -> Prefix<'_, T>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;
let pattern: &[char] = &['a', 'b'];
assert_eq!(pattern.eval(&['a', 'b', 'c']), Some(2));If you are working with ascii or utf8 byte slices, consider byte::utf8