whatwg_infra::strings

Function skip_codepoints

Source
pub fn skip_codepoints<P>(s: &str, position: &mut usize, predicate: P)
where P: Fn(char) -> bool,
Expand description

A non-allocating version of collect_codepoints() for skipping/ignoring a series of codepoints that match a certain predicate.

ยงExamples

use whatwg_infra::skip_codepoints;

let s = "alice_bob";
let mut position = 0usize;

skip_codepoints(s, &mut position, |c| c.is_ascii_alphabetic());

assert_eq!(position, 5);
assert_eq!(&s[position..], "_bob");