Struct IntoIter

struct IntoIter<T> { ... }

Iterator over the bytes contained by the buffer.

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>

fn new(inner: T) -> IntoIter<T>

Creates an iterator over the bytes contained by the buffer.

Examples

use bytes::Bytes;

let buf = Bytes::from_static(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);
fn into_inner(self: Self) -> T

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());
fn get_ref(self: &Self) -> &T

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());
fn get_mut(self: &mut Self) -> &mut T

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'));

impl<I> IntoIterator for IntoIter<T>

fn into_iter(self: Self) -> I

impl<T> Any for IntoIter<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for IntoIter<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for IntoIter<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Freeze for IntoIter<T>

impl<T> From for IntoIter<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for IntoIter<T>

impl<T> Send for IntoIter<T>

impl<T> Sync for IntoIter<T>

impl<T> Unpin for IntoIter<T>

impl<T> UnsafeUnpin for IntoIter<T>

impl<T> UnwindSafe for IntoIter<T>

impl<T, U> Into for IntoIter<T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for IntoIter<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for IntoIter<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: $crate::fmt::Debug> Debug for IntoIter<T>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T: Buf> ExactSizeIterator for IntoIter<T>

impl<T: Buf> Iterator for IntoIter<T>

fn next(self: &mut Self) -> Option<u8>
fn size_hint(self: &Self) -> (usize, Option<usize>)