Struct bitvec::slice::Iter [−][src]
Immutable BitSlice
iterator.
This struct is created by the .iter()
method on BitSlice
s.
Original
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][−]
O: BitOrder,
T: BitStore,
pub fn as_bitslice(&self) -> &'a BitSlice<O, T>ⓘ
[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
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
) -> impl 'a + Iterator<Item = &'a bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
[src][−]
self
) -> impl 'a + Iterator<Item = &'a bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
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
) -> impl 'a + Iterator<Item = bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
[src][−]
self
) -> impl 'a + Iterator<Item = bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
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
) -> impl 'a + Iterator<Item = bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
[src][−]
self
) -> impl 'a + Iterator<Item = bool> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
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][+]
O: BitOrder,
T: BitStore,
impl<O, T> Clone for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src][+]
O: BitOrder,
T: BitStore,
impl<O, T> Debug for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src][+]
O: BitOrder,
T: BitStore,
impl<'a, O, T> DoubleEndedIterator for Iter<'a, O, T> where
O: BitOrder,
T: BitStore,
[src][+]
O: BitOrder,
T: BitStore,
impl<O, T> ExactSizeIterator for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src][+]
O: BitOrder,
T: BitStore,
impl<O, T> FusedIterator for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src]
O: BitOrder,
T: BitStore,
impl<'a, O, T> Iterator for Iter<'a, O, T> where
O: BitOrder,
T: BitStore,
[src][+]
O: BitOrder,
T: BitStore,
impl<O, T> Send for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src]
O: BitOrder,
T: BitStore,
impl<O, T> Sync for Iter<'_, O, T> where
O: BitOrder,
T: BitStore,
[src]
O: BitOrder,
T: BitStore,
Auto Trait Implementations
impl<'a, O, T> RefUnwindSafe for Iter<'a, O, T> where
O: RefUnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Mem: RefUnwindSafe,
O: RefUnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Mem: RefUnwindSafe,
impl<'a, O, T> Unpin for Iter<'a, O, T> where
O: Unpin,
O: Unpin,
impl<'a, O, T> UnwindSafe for Iter<'a, O, T> where
O: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Mem: UnwindSafe,
O: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe,
<T as BitStore>::Mem: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Conv for T
[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][+]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src][+]
I: Iterator,
impl<T> Pipe for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Pipe for T
[src][+]
impl<T> PipeAsRef for T
[src][+]
impl<T> PipeBorrow for T
[src][+]
impl<T> PipeDeref for T
[src][+]
impl<T> PipeRef for T
[src][+]
impl<T> Tap for T
[src][+]
impl<T> Tap for T
[src][+]
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
[src][+]
U: ?Sized,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
[src][+]
U: ?Sized,
impl<T> TapDeref for T
[src][+]
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> TryConv for T
[src][+]
impl<T> TryConv for T
[src][+]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,