[][src]Struct syntect::util::LinesWithEndings

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

An iterator over the lines of a string, including the line endings.

This is similar to the standard library's lines method on str, except that the yielded lines include the trailing newline character(s).

You can use it if you're parsing/highlighting some text that you have as a string. With this, you can use the "newlines" variant of syntax definitions, which is recommended.

Examples

use syntect::util::LinesWithEndings;

let mut lines = LinesWithEndings::from("foo\nbar\nbaz");

assert_eq!(Some("foo\n"), lines.next());
assert_eq!(Some("bar\n"), lines.next());
assert_eq!(Some("baz"), lines.next());

assert_eq!(None, lines.next());

Implementations

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

pub fn from(input: &'a str) -> LinesWithEndings<'a>[src]

Trait Implementations

impl<'a> Iterator for LinesWithEndings<'a>[src]

type Item = &'a str

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for LinesWithEndings<'a>

impl<'a> Send for LinesWithEndings<'a>

impl<'a> Sync for LinesWithEndings<'a>

impl<'a> Unpin for LinesWithEndings<'a>

impl<'a> UnwindSafe for LinesWithEndings<'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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.