pub fn format_user(&self, src: &str) -> String {
        let line = if let Some(span) = self.context.first() {
            src[..span.start].lines().count()
        } else {
            0
        };

        let context = match (self.context.get(0), self.context.get(1)) {
            (Some(inner), Some(outer)) => {
                let first_part = src[outer.start..inner.start].to_string();
                let middle_part = Red.paint(&src[inner.start..inner.end]).to_string();
                let last_part = src[inner.end..outer.end].to_string();

                format!("{}{}{}", first_part, middle_part, last_part)
            }
            (Some(span), None) => src[span.start..span.end].to_string(),
            (_, _) => "no error context available".to_string(),
        };

        format!("{:?} on line {}\n{}", self.kind, line, context)
    }
/// Formats the error using the source code.
///
/// The string will contain the error kind, line number, and surrounding
/// code.
Formats the error using the source code.
The string will contain the error kind, line number, and surrounding
code.
Formats the error using the source code . The string will contain the error kind line number and surrounding code .
pub fn format_user(&self, src: &str) -> String {
        let line = if let Some(span) = self.context.first() {
            src[..span.start].lines().count()
        } else {
            0
        };
        let context = match (self.context.get(0), self.context.get(1)) {
            (Some(inner), Some(outer)) => {
                let first_part = src[outer.start..inner.start].to_string();
                let middle_part = Red.paint(&src[inner.start..inner.end]).to_string();
                let last_part = src[inner.end..outer.end].to_string();
                format!("{}{}{}", first_part, middle_part, last_part)
            }
            (Some(span), None) => src[span.start..span.end].to_string(),
            (_, _) => "no error context available".to_string(),
        };
        format!("{:?} on line {}\n{}", self.kind, line, context)
    }
pub fn format_user ( & self , src : & str ) -> String { let line = if let Some ( span ) = self . context . first ( ) { src [ .. span . start ] . lines ( ) . count ( ) } else { 0 } ; let context = match ( self . context . get ( 0 ) , self . context . get ( 1 ) ) { ( Some ( inner ) , Some ( outer ) ) => { let first_part = src [ outer . start .. inner . start ] . to_string ( ) ; let middle_part = Red . paint ( & src [ inner . start .. inner . end ] ) . to_string ( ) ; let last_part = src [ inner . end .. outer . end ] . to_string ( ) ; format ! ( " " first_part middle_part last_part ) } ( Some ( span ) , None ) => src [ span . start .. span . end ] . to_string ( ) , ( _ , _ ) => " " . to_string ( ) , } ; format ! ( " \n " self kind line context ) }
Formats the error using the source code.
Formats the error using the source code .
&self
src
&str
&self
src
&str