Struct LinesWithTerminator

pub struct LinesWithTerminator<'a> { /* private fields */ }

An iterator over all lines in a byte string, including their terminators.

For this iterator, the only line terminator recognized is \n. (Since line terminators are included, this also handles \r\n line endings.)

Line terminators are only included if they are present in the original byte string. For example, the last line in a byte string may not end with a line terminator.

Concatenating all elements yielded by this iterator is guaranteed to yield the original byte string.

'a is the lifetime of the byte string being iterated over.

Implementations

impl<'a> LinesWithTerminator<'a>

fn as_bytes(&self) -> &'a [u8]

Return a copy of the rest of the underlying bytes without affecting the iterator itself.

Examples

Basic usage:

use bstr::{B, ByteSlice};

let s = b"\
foo
bar\r
baz";
let mut lines = s.lines_with_terminator();
assert_eq!(lines.next(), Some(B("foo\n")));
assert_eq!(lines.as_bytes(), B("bar\r\nbaz"));

Trait Implementations

impl<'a> Clone for LinesWithTerminator<'a>

fn clone(&self) -> LinesWithTerminator<'a>

impl<'a> Debug for LinesWithTerminator<'a>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<'a> DoubleEndedIterator for LinesWithTerminator<'a>

fn next_back(&mut self) -> Option<Self::Item>

impl<'a> FusedIterator for LinesWithTerminator<'a>

impl<'a> Iterator for LinesWithTerminator<'a>

type Item = &'a [u8];
fn next(&mut self) -> Option<&'a [u8]>

Auto Trait Implementations

impl<'a> Freeze for LinesWithTerminator<'a>

impl<'a> RefUnwindSafe for LinesWithTerminator<'a>

impl<'a> Send for LinesWithTerminator<'a>

impl<'a> Sync for LinesWithTerminator<'a>

impl<'a> Unpin for LinesWithTerminator<'a>

impl<'a> UnsafeUnpin for LinesWithTerminator<'a>

impl<'a> UnwindSafe for LinesWithTerminator<'a>

Blanket Implementations

impl<I> IntoIterator for LinesWithTerminator<'a> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for LinesWithTerminator<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for LinesWithTerminator<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for LinesWithTerminator<'a> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for LinesWithTerminator<'a> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for LinesWithTerminator<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for LinesWithTerminator<'a> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for LinesWithTerminator<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for LinesWithTerminator<'a> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for LinesWithTerminator<'a> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>