Returns the previous character in the buffer, positioning the internal cursor to before the character. The next call to `LexBuf::next` will return the same character. # Panics Panics if `prev` is called when the internal cursor is positioned at the beginning of the buffer.
(&mut self)
| 59 | /// Panics if `prev` is called when the internal cursor is positioned at |
| 60 | /// the beginning of the buffer. |
| 61 | pub fn prev(&mut self) -> char { |
| 62 | if let Some(c) = self.buf[..self.pos].chars().rev().next() { |
| 63 | self.pos -= c.len_utf8(); |
| 64 | c |
| 65 | } else { |
| 66 | panic!("LexBuf::prev called on buffer at position 0") |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /// Advances the internal cursor past the next character in the buffer if |
| 71 | /// the character is `ch`. |
no test coverage detected