INNER CODE UNIT · Rust

read_until

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

    fn read_until(&mut self, target: char) -> Result<&'a str, String> {
        let start = self.pos;
        while let Some(ch) = self.peek_char() {
            if ch == target {
                return Ok(&self.input[start..self.pos]);
            }
            self.pos += ch.len_utf8();
        }
        Err(format!("expected '{target}' near byte {}", self.pos))
    }

    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(())
            }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…