Struct bitvec::slice::Iter[][src]

#[repr(transparent)]
pub struct Iter<'a, O, T> where
    O: BitOrder,
    T: BitStore
{ /* fields omitted */ }

Immutable BitSlice iterator.

This struct is created by the .iter() method on BitSlices.

Original

slice::Iter

Examples

Basic usage:

use bitvec::prelude::*;

let bits = bits![0, 1];
for bit in bits.iter() {
  println!("{}", bit);
}

Implementations

impl<'a, O, T> Iter<'a, O, T> where
    O: BitOrder,
    T: BitStore
[src]

pub fn as_bitslice(&self) -> &'a BitSlice<O, T>

Notable traits for &'a BitSlice<O, T>

impl<'a, O, T> Read for &'a BitSlice<O, T> where
    O: BitOrder,
    T: BitStore,
    BitSlice<O, T>: BitField
impl<'a, O, T> Write for &'a mut BitSlice<O, T> where
    O: BitOrder,
    T: BitStore,
    BitSlice<O, T>: BitField
[src]

Views the underlying data as a subslice of the original data.

This has the same lifetime as the original BitSlice, and so the iterator can continue to be used while this exists.

Original

Iter::as_slice

API Differences

As this views a BitSlice, rather than a [T] or [bool] slice, it has been renamed.

Examples

Basic usage:

use bitvec::prelude::*;

let bits = bits![0, 0, 1, 1];

// Get the iterator:
let mut iter = bits.iter();
// So if we print what `as_bitslice` returns
// here, we have "[0011]":
println!("{:b}", iter.as_bitslice());

// Next, we move to the second element of the slice:
iter.next();
// Now `as_bitslice` returns "[011]":
println!("{:b}", iter.as_bitslice());

pub fn by_ref(self) -> BitRefIter<'a, O, T>

Notable traits for BitRefIter<'a, O, T>

impl<'a, O, T> Iterator for BitRefIter<'a, O, T> where
    O: BitOrder,
    T: BitStore
type Item = &'a bool;
[src]

Adapts the iterator to yield &bool references rather than BitRef proxies.

This allows the iterator to be used in APIs that expect ordinary references and are not easily modified to receive the proxy structure.

It works by yielding &'static references to hidden statics; these references will not have an address value that fits in the context of the iterator.

Parameters

  • self

Returns

An iterator equivalent to self, that yields &bool instead of BitRef.

Examples

use bitvec::prelude::*;

let bits = bits![0, 1];
let mut iter = bits.iter().by_ref();
assert_eq!(iter.next(), Some(&false));
assert_eq!(iter.next(), Some(&true));
assert!(iter.next().is_none());

pub fn by_val(self) -> BitValIter<'a, O, T>

Notable traits for BitValIter<'_, O, T>

impl<O, T> Iterator for BitValIter<'_, O, T> where
    O: BitOrder,
    T: BitStore
type Item = bool;
[src]

Adapts the iterator to yield bool values rather than BitRef proxy references.

This allows the iterator to be used in APIs that expect ordinary values. It dereferences the proxy and produces the proxied bool directly.

This is equivalent to [bool].iter().copied(), as Iterator::copied is not available on this iterator.

Parameters

  • self

Returns

An iterator equivalent to self, that yields bool instead of BitRef.

Examples

use bitvec::prelude::*;

let bits = bits![0, 1];
let mut iter = bits.iter().by_val();
assert_eq!(iter.next(), Some(false));
assert_eq!(iter.next(), Some(true));
assert!(iter.next().is_none());

pub fn copied(self) -> BitValIter<'a, O, T>

Notable traits for BitValIter<'_, O, T>

impl<O, T> Iterator for BitValIter<'_, O, T> where
    O: BitOrder,
    T: BitStore
type Item = bool;
[src]

👎 Deprecated:

Iterator::copied does not exist on this iterator. Use by_val instead to achieve the same effect.

Forwards to by_val.

This exists to allow ported code to continue to compile when [bool].iter().copied() is replaced with BitSlice.iter().copied().

However, because Iterator::copied is not available on this iterator, this name raises a deprecation warning and encourages the user to use the correct inherent method instead of the overloaded method name.

Trait Implementations

impl<O, T> AsRef<BitSlice<O, T>> for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<O, T> Clone for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<O, T> Debug for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<'a, O, T> DoubleEndedIterator for Iter<'a, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<O, T> ExactSizeIterator for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<O, T> FusedIterator for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<'a, O, T> Iterator for Iter<'a, O, T> where
    O: BitOrder,
    T: BitStore
[src]

type Item = <usize as BitSliceIndex<'a, O, T>>::Immut

The type of the elements being iterated over.

impl<O, T> Send for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

impl<O, T> Sync for Iter<'_, O, T> where
    O: BitOrder,
    T: BitStore
[src]

Auto Trait Implementations

impl<'a, O, T> RefUnwindSafe for Iter<'a, O, T> where
    O: RefUnwindSafe,
    T: RefUnwindSafe,
    <T as BitStore>::Mem: RefUnwindSafe

impl<'a, O, T> Unpin for Iter<'a, O, T> where
    O: Unpin

impl<'a, O, T> UnwindSafe for Iter<'a, O, T> where
    O: RefUnwindSafe + UnwindSafe,
    T: RefUnwindSafe,
    <T as BitStore>::Mem: UnwindSafe

Blanket Implementations

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

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

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

impl<T> Conv for T[src]

impl<T> FmtForward for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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> Pipe for T where
    T: ?Sized
[src]

impl<T> Tap for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T[src]

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.