INNER CODE UNIT · Rust

expect_char

dontpanic92/OpenPAL3 · crosscom/ccidl-rs/src/lib.rs:656

    fn expect_char(&mut self, expected: char) -> Result<(), String> {
        self.skip_ws();
        match self.peek_char() {
            Some(ch) if ch == expected => {
                self.pos += ch.len_utf8();
                Ok(())
            }
            other => Err(format!(
                "expected '{expected}', found {other:?} near byte {}",
                self.pos
            )),
        }
    }

    fn consume(&mut self, expected: &str) -> bool {
        if self.input[self.pos..].starts_with(expected) {
            self.pos += expected.len();
            true

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…