[][src]Struct line_span::LineSpan

pub struct LineSpan<'a> { /* fields omitted */ }

LineSpan represents a single line, 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());
}

This will output the following:

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

Methods

impl<'a> LineSpan<'a>[src]

pub fn start(&self) -> usize[src]

Returns the byte index of the start of the line.

pub fn end(&self) -> usize[src]

Returns the byte index of the end of the line.

pub fn range(&self) -> Range<usize>[src]

Returns the byte index range of the start and end of the line.

pub fn as_str(&self) -> &'a str[src]

Returns &str of the line, excluding \n and \r\n.

Trait Implementations

impl<'a> Clone for LineSpan<'a>[src]

impl<'a> Copy for LineSpan<'a>[src]

impl<'a> Debug for LineSpan<'a>[src]

fn fmt(&self, fmt: &mut Formatter) -> Result[src]

Renders start and end of LineSpan and as_str as "line".

impl<'a> Deref for LineSpan<'a>[src]

type Target = str

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Returns as_str.

impl<'a> Display for LineSpan<'a>[src]

impl<'a> Eq for LineSpan<'a>[src]

impl<'a> From<LineSpan<'a>> for &'a str[src]

fn from(span: LineSpan<'a>) -> &'a str[src]

Returns as_str.

impl<'a> From<LineSpan<'a>> for Range<usize>[src]

fn from(span: LineSpan<'a>) -> Range<usize>[src]

Returns range.

impl<'a> PartialEq<LineSpan<'a>> for LineSpan<'a>[src]

impl<'a> StructuralEq for LineSpan<'a>[src]

impl<'a> StructuralPartialEq for LineSpan<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for LineSpan<'a>

impl<'a> Send for LineSpan<'a>

impl<'a> Sync for LineSpan<'a>

impl<'a> Unpin for LineSpan<'a>

impl<'a> UnwindSafe for LineSpan<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.