Struct Chain

struct Chain<A, B> { ... }

An iterator that links two iterators together, in a chain.

This struct is created by chain or Iterator::chain. See their documentation for more.

Examples

use std::iter::Chain;
use std::slice::Iter;

let a1 = [1, 2, 3];
let a2 = [4, 5, 6];
let iter: Chain<Iter<'_, _>, Iter<'_, _>> = a1.iter().chain(a2.iter());

Implementations

impl<A, B> DoubleEndedIterator for Chain<A, B>

fn next_back(self: &mut Self) -> Option<<A as >::Item>
fn advance_back_by(self: &mut Self, n: usize) -> Result<(), NonZero<usize>>
fn nth_back(self: &mut Self, n: usize) -> Option<<Self as >::Item>
fn rfind<P>(self: &mut Self, predicate: P) -> Option<<Self as >::Item>
where
    P: FnMut(&<Self as >::Item) -> bool
fn try_rfold<Acc, F, R>(self: &mut Self, acc: Acc, f: F) -> R
where
    Self: Sized,
    F: FnMut(Acc, <Self as >::Item) -> R,
    R: Try<Output = Acc>
fn rfold<Acc, F>(self: Self, acc: Acc, f: F) -> Acc
where
    F: FnMut(Acc, <Self as >::Item) -> Acc

impl<A, B> Freeze for Chain<A, B>

impl<A, B> FusedIterator for Chain<A, B>

impl<A, B> Iterator for Chain<A, B>

fn next(self: &mut Self) -> Option<<A as >::Item>
fn count(self: Self) -> usize
fn try_fold<Acc, F, R>(self: &mut Self, acc: Acc, f: F) -> R
where
    Self: Sized,
    F: FnMut(Acc, <Self as >::Item) -> R,
    R: Try<Output = Acc>
fn fold<Acc, F>(self: Self, acc: Acc, f: F) -> Acc
where
    F: FnMut(Acc, <Self as >::Item) -> Acc
fn advance_by(self: &mut Self, n: usize) -> Result<(), NonZero<usize>>
fn nth(self: &mut Self, n: usize) -> Option<<Self as >::Item>
fn find<P>(self: &mut Self, predicate: P) -> Option<<Self as >::Item>
where
    P: FnMut(&<Self as >::Item) -> bool
fn last(self: Self) -> Option<<A as >::Item>
fn size_hint(self: &Self) -> (usize, Option<usize>)

impl<A, B> RefUnwindSafe for Chain<A, B>

impl<A, B> Send for Chain<A, B>

impl<A, B> Sync for Chain<A, B>

impl<A, B> TrustedLen for Chain<A, B>

impl<A, B> Unpin for Chain<A, B>

impl<A, B> UnsafeUnpin for Chain<A, B>

impl<A, B> UnwindSafe for Chain<A, B>

impl<A: $crate::clone::Clone, B: $crate::clone::Clone> Clone for Chain<A, B>

fn clone(self: &Self) -> Chain<A, B>

impl<A: $crate::fmt::Debug, B: $crate::fmt::Debug> Debug for Chain<A, B>

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

impl<A: Default, B: Default> Default for Chain<A, B>

fn default() -> Self

Creates a Chain from the default values for A and B.

# use core::iter::Chain;
# use core::slice;
# use std::collections::{btree_set, BTreeSet};
# use std::mem;
struct Foo<'a>(Chain<slice::Iter<'a, u8>, btree_set::Iter<'a, u8>>);

let set = BTreeSet::<u8>::new();
let slice: &[u8] = &[];
let mut foo = Foo(slice.iter().chain(set.iter()));

// take requires `Default`
let _: Chain<_, _> = mem::take(&mut foo.0);

impl<I> IntoIterator for Chain<A, B>

fn into_iter(self: Self) -> I

impl<T> Any for Chain<A, B>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Chain<A, B>

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

impl<T> BorrowMut for Chain<A, B>

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

impl<T> CloneToUninit for Chain<A, B>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Chain<A, B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Chain<A, B>

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 Chain<A, B>

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

impl<T, U> TryInto for Chain<A, B>

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