pub fn show<W: Write + WriteColor>(
        &self,
        mut stream: W,
        stylesheet: &Stylesheet,
    ) -> io::Result<()> {
        let mut first_output = true;
        for (idx, line) in self.lines.iter().enumerate() {
            for annotation in line.annotations() {
                let range = annotation.range();

                // Padding
                if first_output {
                    first_output = false;
                } else {
                    stream.write(b"\n")?;
                }

                // Severity and header
                let severity_color = stylesheet.by_severity(&annotation.severity);
                stream.set_color(severity_color)?;
                write!(stream, "{}:", annotation.severity)?;
                if let Some(header) = &annotation.header {
                    write!(stream, " {}\n", header)?;
                } else {
                    stream.write(b"\n")?;
                }

                // Line numbers column & filename
                stream.set_color(&stylesheet.linenr)?;
                let linenr = (idx + 1).to_string();
                let nrcol_width = linenr.len() + 2;
                print_n(&mut stream, b" ", linenr.len() + 1)?;
                write!(stream, "--> ")?;
                stream.set_color(&stylesheet.filename)?;
                write!(
                    stream,
                    "{}:{}:{}\n",
                    self.filename,
                    idx + 1,
                    range.start - line.start() + 1
                )?;
                stream.set_color(&stylesheet.linenr)?;
                print_n(&mut stream, b" ", nrcol_width)?;
                write!(stream, "|\n {} | ", idx + 1)?;

                // Line content
                stream.set_color(&stylesheet.content)?;
                write!(stream, "{}", line.content)?;
                if !line.content.ends_with('\n') {
                    stream.write(b"\n")?;
                }

                // Line numbers column
                stream.set_color(&stylesheet.linenr)?;
                print_n(&mut stream, b" ", nrcol_width)?;
                stream.write(b"|")?;

                // Annotation
                if range.end - range.start != 0 {
                    stream.set_color(severity_color)?;
                    print_n(&mut stream, b" ", range.start - line.start + 1)?;
                    print_n(&mut stream, b"^", range.end - range.start)?;
                    if let Some(text) = &annotation.text {
                        write!(stream, " {}", text)?;
                    }
                }
                stream.write(b"\n")?;
                stream.reset()?;
            }
        }
        Ok(())
    }
/// Print an error message to stream using given stylesheet. If your stream implements
/// [`Write`](std::io::Write), but not [`WriteColor`](termcolor::WriteColor), consider wrapping
/// it into [`termcolor::Ansi`] or [`termcolor::NoColor`].
///
/// This method uses no buffering, so you probably want to pass [`termcolor::Buffer`] to it
/// rather than raw stream.
///
/// If you want to just print message to stdout/stderr, consider using
/// [`.print_stdout()`](AnnotationList::show_stdout) or
/// [`.print_stderr()`](AnnotationList::show_stderr) instead.
Print an error message to stream using given stylesheet.

This method uses no buffering, so you probably want to pass [`termcolor::Buffer`] to it
rather than raw stream.


Print an error message to stream using given stylesheet . This method uses no buffering so you probably want to pass [ ` termcolor :: Buffer ` ] to it rather than raw stream .
pub fn show<W: Write + WriteColor>(
        &self,
        mut stream: W,
        stylesheet: &Stylesheet,
    ) -> io::Result<()> {
        let mut first_output = true;
        for (idx, line) in self.lines.iter().enumerate() {
            for annotation in line.annotations() {
                let range = annotation.range();
                // Padding
                if first_output {
                    first_output = false;
                } else {
                    stream.write(b"\n")?;
                }
                // Severity and header
                let severity_color = stylesheet.by_severity(&annotation.severity);
                stream.set_color(severity_color)?;
                write!(stream, "{}:", annotation.severity)?;
                if let Some(header) = &annotation.header {
                    write!(stream, " {}\n", header)?;
                } else {
                    stream.write(b"\n")?;
                }
                // Line numbers column & filename
                stream.set_color(&stylesheet.linenr)?;
                let linenr = (idx + 1).to_string();
                let nrcol_width = linenr.len() + 2;
                print_n(&mut stream, b" ", linenr.len() + 1)?;
                write!(stream, "--> ")?;
                stream.set_color(&stylesheet.filename)?;
                write!(
                    stream,
                    "{}:{}:{}\n",
                    self.filename,
                    idx + 1,
                    range.start - line.start() + 1
                )?;
                stream.set_color(&stylesheet.linenr)?;
                print_n(&mut stream, b" ", nrcol_width)?;
                write!(stream, "|\n {} | ", idx + 1)?;
                // Line content
                stream.set_color(&stylesheet.content)?;
                write!(stream, "{}", line.content)?;
                if !line.content.ends_with('\n') {
                    stream.write(b"\n")?;
                }
                // Line numbers column
                stream.set_color(&stylesheet.linenr)?;
                print_n(&mut stream, b" ", nrcol_width)?;
                stream.write(b"|")?;
                // Annotation
                if range.end - range.start != 0 {
                    stream.set_color(severity_color)?;
                    print_n(&mut stream, b" ", range.start - line.start + 1)?;
                    print_n(&mut stream, b"^", range.end - range.start)?;
                    if let Some(text) = &annotation.text {
                        write!(stream, " {}", text)?;
                    }
                }
                stream.write(b"\n")?;
                stream.reset()?;
            }
        }
        Ok(())
    }
pub fn show < W : Write + WriteColor > ( & self , mut stream : W , stylesheet : & Stylesheet , ) -> io :: Result < ( ) > { let mut first_output = true ; for ( idx , line ) in self . lines . iter ( ) . enumerate ( ) { for annotation in line . annotations ( ) { let range = annotation . range ( ) ; // Padding if first_output { first_output = false ; } else { stream . write ( b" \n " ) ? ; } // Severity and header let severity_color = stylesheet . by_severity ( & annotation . severity ) ; stream . set_color ( severity_color ) ? ; write ! ( stream " " annotation severity ) ? ; if let Some ( header ) = & annotation . header { write ! ( stream " \n " header ) ? ; } else { stream . write ( b" \n " ) ? ; } // Line numbers column & filename stream . set_color ( & stylesheet . linenr ) ? ; let linenr = ( idx + 1 ) . to_string ( ) ; let nrcol_width = linenr . len ( ) + 2 ; print_n ( & mut stream , b" " , linenr . len ( ) + 1 ) ? ; write ! ( stream " " ) ? ; stream . set_color ( & stylesheet . filename ) ? ; write ! ( stream " \n " self filename idx 1 range start line start ( ) 1 ) ? ; stream . set_color ( & stylesheet . linenr ) ? ; print_n ( & mut stream , b" " , nrcol_width ) ? ; write ! ( stream " \n " idx 1 ) ? ; // Line content stream . set_color ( & stylesheet . content ) ? ; write ! ( stream " " line content ) ? ; if ! line . content . ends_with ( '\n' ) { stream . write ( b" \n " ) ? ; } // Line numbers column stream . set_color ( & stylesheet . linenr ) ? ; print_n ( & mut stream , b" " , nrcol_width ) ? ; stream . write ( b" " ) ? ; // Annotation if range . end - range . start != 0 { stream . set_color ( severity_color ) ? ; print_n ( & mut stream , b" " , range . start - line . start + 1 ) ? ; print_n ( & mut stream , b" " , range . end - range . start ) ? ; if let Some ( text ) = & annotation . text { write ! ( stream " " text ) ? ; } } stream . write ( b" \n " ) ? ; stream . reset ( ) ? ; } } Ok ( ( ) ) }
Print an error message to stream using given stylesheet.
Print an error message to stream using given stylesheet .
&self
stream
W
stylesheet
&Stylesheet
&self
stream
W
stylesheet
&Stylesheet