pub fn line_for(source: &Source, span: Span) -> Option<(usize, &str, Span)> {
    let line_starts = source.line_starts();

    let line = match line_starts.binary_search(&span.start.into_usize()) {
        Ok(n) => n,
        Err(n) => n.saturating_sub(1),
    };

    let start = *line_starts.get(line)?;
    let end = line.checked_add(1)?;

    let s = if let Some(end) = line_starts.get(end) {
        source.get(start..*end)?
    } else {
        source.get(start..)?
    };

    Some((
        line,
        s,
        Span::new(
            span.start.into_usize() - start,
            span.end.into_usize() - start,
        ),
    ))
}
/// Get the line number and source line for the given source and span.
Get the line number and source line for the given source and span.
Get the line number and source line for the given source and span .
pub fn line_for(source: &Source, span: Span) -> Option<(usize, &str, Span)> {
    let line_starts = source.line_starts();
    let line = match line_starts.binary_search(&span.start.into_usize()) {
        Ok(n) => n,
        Err(n) => n.saturating_sub(1),
    };
    let start = *line_starts.get(line)?;
    let end = line.checked_add(1)?;
    let s = if let Some(end) = line_starts.get(end) {
        source.get(start..*end)?
    } else {
        source.get(start..)?
    };
    Some((
        line,
        s,
        Span::new(
            span.start.into_usize() - start,
            span.end.into_usize() - start,
        ),
    ))
}
pub fn line_for ( source : & Source , span : Span ) -> Option < ( usize , & str , Span ) > { let line_starts = source . line_starts ( ) ; let line = match line_starts . binary_search ( & span . start . into_usize ( ) ) { Ok ( n ) => n , Err ( n ) => n . saturating_sub ( 1 ) , } ; let start = * line_starts . get ( line ) ? ; let end = line . checked_add ( 1 ) ? ; let s = if let Some ( end ) = line_starts . get ( end ) { source . get ( start .. * end ) ? } else { source . get ( start .. ) ? } ; Some ( ( line , s , Span :: new ( span . start . into_usize ( ) - start , span . end . into_usize ( ) - start , ) , ) ) }
Get the line number and source line for the given source and span.
Get the line number and source line for the given source and span .
source
&Source
span
Span
source
&Source
span
Span