Struct grep_searcher::LineStep

source ·
pub struct LineStep { /* private fields */ }
Expand description

An explicit iterator over lines in a particular slice of bytes.

This iterator avoids borrowing the bytes themselves, and instead requires callers to explicitly provide the bytes when moving through the iterator. While not idiomatic, this provides a simple way of iterating over lines that doesn’t require borrowing the slice itself, which can be convenient.

Line terminators are considered part of the line they terminate. All lines yielded by the iterator are guaranteed to be non-empty.

Implementations§

source§

impl LineStep

source

pub fn new(line_term: u8, start: usize, end: usize) -> LineStep

Create a new line iterator over the given range of bytes using the given line terminator.

Callers should provide the actual bytes for each call to next. The same slice must be provided to each call.

This panics if start is not less than or equal to end.

source

pub fn next(&mut self, bytes: &[u8]) -> Option<(usize, usize)>

Return the start and end position of the next line in the given bytes.

The caller must past exactly the same slice of bytes for each call to next.

The range returned includes the line terminator. Ranges are always non-empty.

Trait Implementations§

source§

impl Debug for LineStep

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.