pub fn collect_codepoints<P>(
s: &str,
position: &mut usize,
predicate: P,
) -> String
Expand description
Collects a sequence of Unicode codepoints given a predicate function and position to move forward.
See also: WHATWG Infra Standard definition
ยงExamples
use whatwg_infra::collect_codepoints;
let value = "test1";
let mut position = 0usize;
let collected = collect_codepoints(value, &mut position, |c| c.is_ascii_alphabetic());
assert_eq!(collected, String::from("test"));
assert_eq!(position, 4);