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§
Sourcefn line_spans(&self) -> LineSpanIter<'_> ⓘ
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
impl LineSpans for str
fn line_spans(&self) -> LineSpanIter<'_> ⓘ
Source§impl LineSpans for String
Available on crate feature alloc only.
impl LineSpans for String
Available on crate feature
alloc only.