Struct LinesWithTerminator

struct LinesWithTerminator<'a> { ... }

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: &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"));

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

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

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

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

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

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

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

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

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

fn next(self: &mut Self) -> Option<&'a [u8]>

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>

impl<I> IntoIterator for LinesWithTerminator<'a>

fn into_iter(self: Self) -> I

impl<T> Any for LinesWithTerminator<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for LinesWithTerminator<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for LinesWithTerminator<'a>

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

impl<T> CloneToUninit for LinesWithTerminator<'a>

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

impl<T> From for LinesWithTerminator<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for LinesWithTerminator<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for LinesWithTerminator<'a>

fn into(self: 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 for LinesWithTerminator<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for LinesWithTerminator<'a>

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