pub fn into_report(self, name: impl AsRef<str>, mut input: String) -> ParseErrorReport {
        if input.is_empty() {
            // fixes miette panic: get_lines should always return at least one line?
            input = String::from("\n");
        }
        let location = if self.span.start_offset == input.len() {
            let source_span_offset = input.len() - 1;
            let source_span_length = 0;
            (source_span_offset, source_span_length).into()
        } else {
            let source_span_offset = self.span.start_offset;
            let source_span_length = self.span.end_offset - self.span.start_offset;
            (source_span_offset, source_span_length).into()
        };

        let input = NamedSource::new(name, input);

        // positives -> expected
        // negatives -> unexpected
        // https://github.com/pest-parser/pest/blob/b2c350862f52f3b51f6a32c79727e3dec3a408ad/pest/src/error.rs#L354
        match (self.positives.is_empty(), self.negatives.is_empty()) {
            (true, true) => ParseErrorReport::Unhelpful { input, location },
            (false, true) => ParseErrorReport::Expected {
                input,
                location,
                expected: self.positives.join(", "),
            },
            (true, false) => ParseErrorReport::Unexpected {
                input,
                location,
                unexpected: self.negatives.join(", "),
            },
            (false, false) => ParseErrorReport::Helpful {
                input,
                expected_location: location,
                expected: self.positives.join(", "),
                unexpected_location: location,
                unexpected: self.negatives.join(", "),
            },
        }
    }
/// Create a pretty error report.
Create a pretty error report.
Create a pretty error report .
pub fn into_report(self, name: impl AsRef<str>, mut input: String) -> ParseErrorReport {
        if input.is_empty() {
            // fixes miette panic: get_lines should always return at least one line?
            input = String::from("\n");
        }
        let location = if self.span.start_offset == input.len() {
            let source_span_offset = input.len() - 1;
            let source_span_length = 0;
            (source_span_offset, source_span_length).into()
        } else {
            let source_span_offset = self.span.start_offset;
            let source_span_length = self.span.end_offset - self.span.start_offset;
            (source_span_offset, source_span_length).into()
        };
        let input = NamedSource::new(name, input);
        // positives -> expected
        // negatives -> unexpected
        // https://github.com/pest-parser/pest/blob/b2c350862f52f3b51f6a32c79727e3dec3a408ad/pest/src/error.rs#L354
        match (self.positives.is_empty(), self.negatives.is_empty()) {
            (true, true) => ParseErrorReport::Unhelpful { input, location },
            (false, true) => ParseErrorReport::Expected {
                input,
                location,
                expected: self.positives.join(", "),
            },
            (true, false) => ParseErrorReport::Unexpected {
                input,
                location,
                unexpected: self.negatives.join(", "),
            },
            (false, false) => ParseErrorReport::Helpful {
                input,
                expected_location: location,
                expected: self.positives.join(", "),
                unexpected_location: location,
                unexpected: self.negatives.join(", "),
            },
        }
    }
pub fn into_report ( self , name : impl AsRef < str > , mut input : String ) -> ParseErrorReport { if input . is_empty ( ) { // fixes miette panic: get_lines should always return at least one line? input = String :: from ( " \n " ) ; } let location = if self . span . start_offset == input . len ( ) { let source_span_offset = input . len ( ) - 1 ; let source_span_length = 0 ; ( source_span_offset , source_span_length ) . into ( ) } else { let source_span_offset = self . span . start_offset ; let source_span_length = self . span . end_offset - self . span . start_offset ; ( source_span_offset , source_span_length ) . into ( ) } ; let input = NamedSource :: new ( name , input ) ; // positives -> expected // negatives -> unexpected // https://github.com/pest-parser/pest/blob/b2c350862f52f3b51f6a32c79727e3dec3a408ad/pest/src/error.rs#L354 match ( self . positives . is_empty ( ) , self . negatives . is_empty ( ) ) { ( true , true ) => ParseErrorReport :: Unhelpful { input , location } , ( false , true ) => ParseErrorReport :: Expected { input , location , expected : self . positives . join ( " " ) , } , ( true , false ) => ParseErrorReport :: Unexpected { input , location , unexpected : self . negatives . join ( " " ) , } , ( false , false ) => ParseErrorReport :: Helpful { input , expected_location : location , expected : self . positives . join ( " " ) , unexpected_location : location , unexpected : self . negatives . join ( " " ) , } , } }
Create a pretty error report.
Create a pretty error report .
self
name
impl AsRef<str>
input
String
self
name
impl AsRef<str>
input
String