MCPcopy Create free account
hub / github.com/bytesize-rs/bytesize / take_while

Function take_while

src/parse.rs:37–47  ·  view source on GitHub ↗
(s: &str, mut predicate: P)

Source from the content-addressed store, hash-verified

35}
36
37fn take_while<P>(s: &str, mut predicate: P) -> &str
38where
39 P: FnMut(char) -> bool,
40{
41 let offset = s
42 .chars()
43 .take_while(|ch| predicate(*ch))
44 .map(|ch| ch.len_utf8())
45 .sum();
46 &s[..offset]
47}
48
49fn skip_while<P>(s: &str, mut predicate: P) -> &str
50where

Callers 1

from_strMethod · 0.85

Calls 1

sumMethod · 0.80

Tested by

no test coverage detected