fn apply_line(line: &str, styles: &[(SingleLineSpan, Style)]) -> String {
    if styles.is_empty() && !line.is_empty() {
        return highlight_missing_style_bug(line);
    }

    let line_bytes = byte_len(line);
    let mut res = String::with_capacity(line.len());
    let mut i = 0;
    for (span, style) in styles {
        // The remaining spans are beyond the end of this line. This
        // occurs when we truncate the line to fit on the display.
        if span.start_col >= line_bytes {
            break;
        }

        // Unstyled text before the next span.
        if i < span.start_col {
            res.push_str(substring_by_byte(line, i, span.start_col));
        }

        // Apply style to the substring in this span.
        let span_s = substring_by_byte(line, span.start_col, min(line_bytes, span.end_col));
        res.push_str(&span_s.style(*style).to_string());
        i = span.end_col;
    }

    // Unstyled text after the last span.
    if i < line_bytes {
        let span_s = substring_by_byte(line, i, line_bytes);
        res.push_str(span_s);
    }
    res
}
/// Return a copy of `line` with styles applied to all the spans
/// specified.
Return a copy of `line` with styles applied to all the spans
specified.
Return a copy of ` line ` with styles applied to all the spans specified .
fn apply_line(line: &str, styles: &[(SingleLineSpan, Style)]) -> String {
    if styles.is_empty() && !line.is_empty() {
        return highlight_missing_style_bug(line);
    }
    let line_bytes = byte_len(line);
    let mut res = String::with_capacity(line.len());
    let mut i = 0;
    for (span, style) in styles {
        // The remaining spans are beyond the end of this line. This
        // occurs when we truncate the line to fit on the display.
        if span.start_col >= line_bytes {
            break;
        }
        // Unstyled text before the next span.
        if i < span.start_col {
            res.push_str(substring_by_byte(line, i, span.start_col));
        }
        // Apply style to the substring in this span.
        let span_s = substring_by_byte(line, span.start_col, min(line_bytes, span.end_col));
        res.push_str(&span_s.style(*style).to_string());
        i = span.end_col;
    }
    // Unstyled text after the last span.
    if i < line_bytes {
        let span_s = substring_by_byte(line, i, line_bytes);
        res.push_str(span_s);
    }
    res
}
fn apply_line ( line : & str , styles : & [ ( SingleLineSpan , Style ) ] ) -> String { if styles . is_empty ( ) && ! line . is_empty ( ) { return highlight_missing_style_bug ( line ) ; } let line_bytes = byte_len ( line ) ; let mut res = String :: with_capacity ( line . len ( ) ) ; let mut i = 0 ; for ( span , style ) in styles { // The remaining spans are beyond the end of this line. This // occurs when we truncate the line to fit on the display. if span . start_col >= line_bytes { break ; } // Unstyled text before the next span. if i < span . start_col { res . push_str ( substring_by_byte ( line , i , span . start_col ) ) ; } // Apply style to the substring in this span. let span_s = substring_by_byte ( line , span . start_col , min ( line_bytes , span . end_col ) ) ; res . push_str ( & span_s . style ( * style ) . to_string ( ) ) ; i = span . end_col ; } // Unstyled text after the last span. if i < line_bytes { let span_s = substring_by_byte ( line , i , line_bytes ) ; res . push_str ( span_s ) ; } res }
Return a copy of `line` with styles applied to all the spans
specified.
Return a copy of ` line ` with styles applied to all the spans specified .
line
&str
styles
&[(SingleLineSpan, Style)]