pub fn next_char(&mut self) -> Result<bool, GraphemeIncomplete> {
        // Next character starts immediately after the current one.
        self.pos.byte_offset = self.pos.byte_offset + self.pos.char_size;
        self.grc.set_cursor(self.pos.byte_offset);
        // Check next character and determine its size in bytes.
        // char_size == 0 encodes exceptional cases:
        //      - position before the first char
        //      - position after the last char
        //      - position at a malformed unicode grapheme
        let res = match self.grc.next_boundary(self.str, 0) {
            Ok(Some(end)) => {
                self.pos.char_size = end - self.pos.byte_offset;
                Ok(true)
            }
            Ok(None) => {
                self.pos.char_size = 0;
                Ok(false)
            }
            Err(err) => {
                self.pos.char_size = 0;
                Err(err)
            }
        };
        // Returns "" before the start, at the end of string, at the error.
        let prev_char = self.current_char();
        // Update line and column depending on previous char.
        match prev_char {
            "\n" | "\r\n" => {
                self.pos.line += 1;
                self.pos.col = 1;
            }
            "\t" => self.pos.col += 4, // FIXME: tab_size
            "" => {}
            _ => self.pos.col += 1,
        }
        res
    }
/// Advances cursor forward.
/// Returns false if EOF, returns error if next grapheme is malformed.
Advances cursor forward.
Returns false if EOF, returns error if next grapheme is malformed.
Advances cursor forward . Returns false if EOF returns error if next grapheme is malformed .
pub fn next_char(&mut self) -> Result<bool, GraphemeIncomplete> {
        // Next character starts immediately after the current one.
        self.pos.byte_offset = self.pos.byte_offset + self.pos.char_size;
        self.grc.set_cursor(self.pos.byte_offset);
        // Check next character and determine its size in bytes.
        // char_size == 0 encodes exceptional cases:
        //      - position before the first char
        //      - position after the last char
        //      - position at a malformed unicode grapheme
        let res = match self.grc.next_boundary(self.str, 0) {
            Ok(Some(end)) => {
                self.pos.char_size = end - self.pos.byte_offset;
                Ok(true)
            }
            Ok(None) => {
                self.pos.char_size = 0;
                Ok(false)
            }
            Err(err) => {
                self.pos.char_size = 0;
                Err(err)
            }
        };
        // Returns "" before the start, at the end of string, at the error.
        let prev_char = self.current_char();
        // Update line and column depending on previous char.
        match prev_char {
            "\n" | "\r\n" => {
                self.pos.line += 1;
                self.pos.col = 1;
            }
            "\t" => self.pos.col += 4, // FIXME: tab_size
            "" => {}
            _ => self.pos.col += 1,
        }
        res
    }
pub fn next_char ( & mut self ) -> Result < bool , GraphemeIncomplete > { // Next character starts immediately after the current one. self . pos . byte_offset = self . pos . byte_offset + self . pos . char_size ; self . grc . set_cursor ( self . pos . byte_offset ) ; // Check next character and determine its size in bytes. // char_size == 0 encodes exceptional cases: //      - position before the first char //      - position after the last char //      - position at a malformed unicode grapheme let res = match self . grc . next_boundary ( self . str , 0 ) { Ok ( Some ( end ) ) => { self . pos . char_size = end - self . pos . byte_offset ; Ok ( true ) } Ok ( None ) => { self . pos . char_size = 0 ; Ok ( false ) } Err ( err ) => { self . pos . char_size = 0 ; Err ( err ) } } ; // Returns "" before the start, at the end of string, at the error. let prev_char = self . current_char ( ) ; // Update line and column depending on previous char. match prev_char { " \n " | " \r \n " => { self . pos . line += 1 ; self . pos . col = 1 ; } " \t " => self . pos . col += 4 , // FIXME: tab_size " " => { } _ => self . pos . col += 1 , } res }
Advances cursor forward.
Advances cursor forward .
&mut self
&mut self