[][src]Struct bytes::buf::IntoIter

pub struct IntoIter<T> { /* fields omitted */ }

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]

type Item = u8

The type of the elements being iterated over.

Auto Trait Implementations

impl<T> RefUnwindSafe for IntoIter<T> where
    T: RefUnwindSafe

impl<T> Send for IntoIter<T> where
    T: Send

impl<T> Sync for IntoIter<T> where
    T: Sync

impl<T> Unpin for IntoIter<T> where
    T: Unpin

impl<T> UnwindSafe for IntoIter<T> where
    T: 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> 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, 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.