mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 04:40:47 +01:00
even less nom
This commit is contained in:
parent
41d558ecb0
commit
19f9c9f973
4 changed files with 74 additions and 56 deletions
|
|
@ -337,6 +337,16 @@ pub fn split_once(input: &str, delim: u8, offset: usize) -> Result<(&str, &str)>
|
|||
})
|
||||
}
|
||||
|
||||
pub fn take_until(input: &str, delim: u8) -> (&str, &str) {
|
||||
debug_assert!(delim < 128); // only basic ascii
|
||||
if let Some(end) = memchr(delim, input.as_bytes()) {
|
||||
// safety, memchr returns indices that are inside the input length and we only split on ascii
|
||||
unsafe { (input.get_unchecked(end..), input.get_unchecked(..end)) }
|
||||
} else {
|
||||
("", input)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn skip(input: &str, count: usize) -> Result<&str> {
|
||||
input.get(count..).ok_or(Error::Incomplete)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue