Skip to main content

LineSpans

Trait 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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl LineSpans for str

Source§

impl LineSpans for String

Available on crate feature alloc only.

Implementors§