Struct line_span::LineSpan [−][src]
pub struct LineSpan<'a> { /* fields omitted */ }
Expand description
LineSpan
represents a single line. It is possible to
get a &str
of the line both including and excluding
\n
and \r\n
.
use line_span::LineSpans;
let text = "foo\nbar\r\nbaz";
for span in text.line_spans() {
println!(
"{:>2?}: {:?} {:?}",
span.range(),
span.as_str(),
span.as_str_with_ending(),
);
}
This will output the following:
0.. 3: "foo" "foo\n"
4.. 7: "bar" "bar\r\n"
9..12: "baz" "baz"
Implementations
Returns the byte index of the end of the line,
excluding the line ending part \n
or \r\n
.
To include the line ending part, then use ending
.
Returns the byte index of the end of the line,
including the line ending part \n
or \r\n
.
To exclude the line ending part, then use end
.
Returns the byte index range of the start and
end of the line, excluding the line ending
part \n
or \r\n
.
To include the line ending part, then use range_with_ending
.
Returns the byte index range of the start and
end of the line, including the line ending
part \n
or \r\n
.
To exclude the line ending part, then use range
.
Returns &str
of the line, excluding \n
and \r\n
.
To include the line ending part, then use as_str_with_ending
.
Returns &str
of the line, including \n
and \r\n
.
To exclude the line ending part, then use as_str
.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for LineSpan<'a>
impl<'a> UnwindSafe for LineSpan<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more