Trait line_span::LineSpans

source ·
pub trait LineSpans {
    // Required method
    fn line_spans(&self) -> LineSpanIter<'_> ;
}
Expand description

Trait which implements line_spans() to get a LineSpanIter.

use line_span::LineSpans;

let text = "foo\nbar\r\nbaz";

for span in text.line_spans() {
    println!("{:>2?}: {:?}", span.range(), span.as_str());
}

This will output the following:

 0.. 3: "foo"
 4.. 7: "bar"
 9..12: "baz"

Required Methods§

source

fn line_spans(&self) -> LineSpanIter<'_>

Creates a LineSpanIter.

Implementations on Foreign Types§

source§

impl LineSpans for String

source§

impl LineSpans for str

Implementors§