fn highlight(&self, src: &str) -> String {
        if self.start_line != self.end_line {
            self.highlight_multiline(src)
        } else {
            let mut s = format!(
                "at line {}, col {}:\n",
                self.start_line, self.start_col
            );

            for (i, line) in src.split("\n").enumerate() {
                let line_no = i + 1;

                // Print two lines of context
                if line_no > self.start_line.saturating_sub(Self::CONTEXT_LINES)
                    && line_no
                        < self.start_line.saturating_add(Self::CONTEXT_LINES)
                {
                    s.push_str(&format!("{:04} > ", line_no));
                    s.push_str(line);
                    s.push('\n');
                }

                // Print uppercut chars indicating the section that
                // caused the error.
                if line_no == self.start_line {
                    s.push_str("       "); // to match the start line indicator
                    for i in 0..(self.end_col - 1) {
                        let col_no = i + 1;

                        if col_no < self.start_col {
                            s.push(' ');
                        } else {
                            s.push('^');
                        }
                    }
                    s.push('\n');
                }
            }

            s
        }
    }
/// Return a string highlighting the given positional span.
Return a string highlighting the given positional span.
Return a string highlighting the given positional span .
fn highlight(&self, src: &str) -> String {
        if self.start_line != self.end_line {
            self.highlight_multiline(src)
        } else {
            let mut s = format!(
                "at line {}, col {}:\n",
                self.start_line, self.start_col
            );
            for (i, line) in src.split("\n").enumerate() {
                let line_no = i + 1;
                // Print two lines of context
                if line_no > self.start_line.saturating_sub(Self::CONTEXT_LINES)
                    && line_no
                        < self.start_line.saturating_add(Self::CONTEXT_LINES)
                {
                    s.push_str(&format!("{:04} > ", line_no));
                    s.push_str(line);
                    s.push('\n');
                }
                // Print uppercut chars indicating the section that
                // caused the error.
                if line_no == self.start_line {
                    s.push_str("       "); // to match the start line indicator
                    for i in 0..(self.end_col - 1) {
                        let col_no = i + 1;
                        if col_no < self.start_col {
                            s.push(' ');
                        } else {
                            s.push('^');
                        }
                    }
                    s.push('\n');
                }
            }
            s
        }
    }
fn highlight ( & self , src : & str ) -> String { if self . start_line != self . end_line { self . highlight_multiline ( src ) } else { let mut s = format ! ( " \n " self start_line self start_col ) ; for ( i , line ) in src . split ( " \n " ) . enumerate ( ) { let line_no = i + 1 ; // Print two lines of context if line_no > self . start_line . saturating_sub ( Self :: CONTEXT_LINES ) && line_no < self . start_line . saturating_add ( Self :: CONTEXT_LINES ) { s . push_str ( & format ! ( " " line_no ) ) ; s . push_str ( line ) ; s . push ( '\n' ) ; } // Print uppercut chars indicating the section that // caused the error. if line_no == self . start_line { s . push_str ( " " ) ; // to match the start line indicator for i in 0 .. ( self . end_col - 1 ) { let col_no = i + 1 ; if col_no < self . start_col { s . push ( ' ' ) ; } else { s . push ( '^' ) ; } } s . push ( '\n' ) ; } } s } }
Return a string highlighting the given positional span.
Return a string highlighting the given positional span .
&self
src
&str