[][src]Struct bitvec::slice::Windows

pub struct Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
{ /* fields omitted */ }

State keeper for sliding-window iteration over a BitSlice.

Type Parameters

  • C: Cursor: The bit-order type of the underlying BitSlice.
  • T: 'a + BitStore: The storage type of the underlying BitSlice.

Lifetimes

  • 'a: The lifetime of the underlying BitSlice.

Trait Implementations

impl<'a, C, T> Iterator for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

type Item = &'a BitSlice<C, T>

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src]

Advances the iterator by one, returning the first window in it (if any).

Parameters

  • &mut self

Returns

The leading window in the iterator, if any.

Examples

use bitvec::prelude::*;

let bits = &1u8.as_bitslice::<LittleEndian>()[.. 2];
let mut iter = bits.iter();
assert!(iter.next().unwrap());
assert!(!iter.next().unwrap());
assert!(iter.next().is_none());

fn size_hint(&self) -> (usize, Option<usize>)[src]

Hints at the number of windows remaining in the iterator.

Because the exact size is always known, this always produces (len, Some(len)).

Parameters

  • &self

Returns

  • usize: The minimum windows remaining.
  • Option<usize>: The maximum windows remaining.

Examples

use bitvec::prelude::*;

let bits = &0x4Bu8.as_bitslice::<BigEndian>()[.. 2];
let mut iter = bits.iter();
assert_eq!(iter.size_hint(), (2, Some(2)));
iter.next();
assert_eq!(iter.size_hint(), (1, Some(1)));
iter.next();
assert_eq!(iter.size_hint(), (0, Some(0)));

fn count(self) -> usize[src]

Counts how many windows are live in the iterator, consuming it.

Parameters

  • self

Returns

The number of windows remaining in the iterator.

Examples

use bitvec::prelude::*;

let bits = 0x4Bu8.as_bitslice::<BigEndian>();
assert_eq!(bits.iter().count(), 8);

fn nth(&mut self, n: usize) -> Option<Self::Item>[src]

Advances the iterator by n windows, starting from zero.

Parameters

  • &mut self
  • n: The number of windows to skip, before producing the next bit after the skips. If this overshoots the iterator’s remaining length, then the iterator is marked empty before returning None.

Returns

If n does not overshoot the iterator’s bounds, this produces the nth bit after advancing the iterator to it, discarding the intermediate windows.

If n does overshoot the iterator’s bounds, this empties the iterator and returns None.

Examples

use bitvec::prelude::*;

let bits = 2u8.as_bitslice::<BigEndian>();
let mut iter = bits.iter();
assert!(iter.nth(6).unwrap());
assert!(!iter.nth(0).unwrap());
assert!(iter.nth(0).is_none());

fn last(self) -> Option<Self::Item>[src]

Consumes the iterator, returning only the final window.

Parameters

  • self

Returns

The last window in the iterator slice, if any.

Examples

use bitvec::prelude::*;

let bits = 0x4Bu8.as_bitslice::<BigEndian>();
assert_eq!(bits.windows(3).last(), Some(&bits[5 ..]));

impl<'a, C, T> DoubleEndedIterator for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

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

Produces the next window from the back of the slice.

Parameters

  • &mut self

Returns

The last window in the slice, if any.

Examples

use bitvec::prelude::*;

let store: &[u8] = &[0b0010_1101];
let bits: &BitSlice = store.into();
let mut windows = bits[2 .. 7].windows(3);
assert_eq!(windows.next_back(), Some(&bits[4 .. 7]));
assert_eq!(windows.next_back(), Some(&bits[3 .. 6]));
assert_eq!(windows.next_back(), Some(&bits[2 .. 5]));
assert!(windows.next_back().is_none());

impl<'a, C, T> ExactSizeIterator for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

Mark that the iterator has an exact size.

impl<'a, C: Clone, T: Clone> Clone for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

impl<'a, C: Debug, T: Debug> Debug for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

impl<'a, C, T> FusedIterator for Windows<'a, C, T> where
    C: Cursor,
    T: 'a + BitStore
[src]

Mark that the iterator will not resume after halting.

Auto Trait Implementations

impl<'a, C, T> Send for Windows<'a, C, T>

impl<'a, C, T> Sync for Windows<'a, C, T>

impl<'a, C, T> Unpin for Windows<'a, C, T>

impl<'a, C, T> UnwindSafe for Windows<'a, C, T> where
    C: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, C, T> RefUnwindSafe for Windows<'a, C, T> where
    C: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for 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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]