[−][src]Struct bytes::buf::IntoIter
Iterator over the bytes contained by the buffer.
This struct is created by the iter
method on Buf
.
Examples
Basic usage:
use bytes::Bytes; let buf = Bytes::from(&b"abc"[..]); let mut iter = buf.into_iter(); assert_eq!(iter.next(), Some(b'a')); assert_eq!(iter.next(), Some(b'b')); assert_eq!(iter.next(), Some(b'c')); assert_eq!(iter.next(), None);
Implementations
impl<T> IntoIter<T>
[src][−]
pub fn new(inner: T) -> IntoIter<T>
[src][−]
Creates an iterator over the bytes contained by the buffer.
Examples
use bytes::Bytes; use bytes::buf::IntoIter; let buf = Bytes::from_static(b"abc"); let mut iter = IntoIter::new(buf); assert_eq!(iter.next(), Some(b'a')); assert_eq!(iter.next(), Some(b'b')); assert_eq!(iter.next(), Some(b'c')); assert_eq!(iter.next(), None);
pub fn into_inner(self) -> T
[src][−]
Consumes this IntoIter
, returning the underlying value.
Examples
use bytes::{Buf, Bytes}; let buf = Bytes::from(&b"abc"[..]); let mut iter = buf.into_iter(); assert_eq!(iter.next(), Some(b'a')); let buf = iter.into_inner(); assert_eq!(2, buf.remaining());
pub fn get_ref(&self) -> &T
[src][−]
Gets a reference to the underlying Buf
.
It is inadvisable to directly read from the underlying Buf
.
Examples
use bytes::{Buf, Bytes}; let buf = Bytes::from(&b"abc"[..]); let mut iter = buf.into_iter(); assert_eq!(iter.next(), Some(b'a')); assert_eq!(2, iter.get_ref().remaining());
pub fn get_mut(&mut self) -> &mut T
[src][−]
Gets a mutable reference to the underlying Buf
.
It is inadvisable to directly read from the underlying Buf
.
Examples
use bytes::{Buf, BytesMut}; let buf = BytesMut::from(&b"abc"[..]); let mut iter = buf.into_iter(); assert_eq!(iter.next(), Some(b'a')); iter.get_mut().advance(1); assert_eq!(iter.next(), Some(b'c'));
Trait Implementations
impl<T: Debug> Debug for IntoIter<T>
[src][+]
impl<T: Buf> ExactSizeIterator for IntoIter<T>
[src][+]
impl<T: Buf> Iterator for IntoIter<T>
[src][+]
Auto Trait Implementations
impl<T> RefUnwindSafe for IntoIter<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for IntoIter<T> where
T: Send,
T: Send,
impl<T> Sync for IntoIter<T> where
T: Sync,
T: Sync,
impl<T> Unpin for IntoIter<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for IntoIter<T> where
T: UnwindSafe,
T: 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> 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, 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>,