mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 04:40:47 +01:00
less nom
This commit is contained in:
parent
c06e09e691
commit
b9b4ad619b
3 changed files with 54 additions and 33 deletions
|
|
@ -330,6 +330,18 @@ pub fn split_once(input: &str, delim: u8, offset: usize) -> Result<(&str, &str)>
|
|||
Ok((&input[..end], &input[(end + offset)..]))
|
||||
}
|
||||
|
||||
pub fn skip(input: &str, count: usize) -> Result<&str> {
|
||||
input.get(count..).ok_or(Error::Incomplete)
|
||||
}
|
||||
|
||||
pub fn skip_matches(input: &str, char: u8) -> (&str, bool) {
|
||||
if input.as_bytes().get(0) == Some(&char) {
|
||||
(&input[1..], true)
|
||||
} else {
|
||||
(input, false)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_between_end(input: &str, start: u8, end: u8) -> Option<&str> {
|
||||
let end = memrchr(end, input.as_bytes())?;
|
||||
let start = memrchr(start, &input.as_bytes()[0..end])?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue