SpansBy

Struct SpansBy 

Source
pub struct SpansBy<I: Iterator, K, F> { /* private fields */ }
Expand description

SpansBy wraps an iterator and provides progressive access to contiguous spans of the iterator.

See Spans::spans_by_key for more information.

Implementations§

Source§

impl<I, K, C, F> SpansBy<I, K, F>
where I: Iterator, K: Fn(&I::Item) -> C, C: Copy, F: Fn(C, C) -> bool,

Source

pub fn next(&mut self) -> Option<Span<'_, I, K, C, F>>

Returns the next span or None if the iterator terminated.

§Example
use spans::Spans;

let vec = vec![1, 2, 5];
let mut spans = vec.iter().spans_by_key(|&&x| x, |a, b| a + 1 == b);

while let Some(span) = spans.next() {
    // do something with `span`
    let count = span.count();
    assert!(count > 0); // true for all spans
    assert!(count < 3); // true for the spans in this example
}

Auto Trait Implementations§

§

impl<I, K, F> Freeze for SpansBy<I, K, F>
where K: Freeze, F: Freeze, I: Freeze, <I as Iterator>::Item: Freeze,

§

impl<I, K, F> RefUnwindSafe for SpansBy<I, K, F>

§

impl<I, K, F> Send for SpansBy<I, K, F>
where K: Send, F: Send, I: Send, <I as Iterator>::Item: Send,

§

impl<I, K, F> Sync for SpansBy<I, K, F>
where K: Sync, F: Sync, I: Sync, <I as Iterator>::Item: Sync,

§

impl<I, K, F> Unpin for SpansBy<I, K, F>
where K: Unpin, F: Unpin, I: Unpin, <I as Iterator>::Item: Unpin,

§

impl<I, K, F> UnwindSafe for SpansBy<I, K, F>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.