Struct Chain

pub struct Chain<'a> { /* private fields */ }

Iterator of a chain of source errors.

This type is the iterator returned by Error::chain.

Example

use anyhow::Error;
use std::io;

pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {
    for cause in error.chain() {
        if let Some(io_error) = cause.downcast_ref::<io::Error>() {
            return Some(io_error.kind());
        }
    }
    None
}

Implementations

impl<'a> Chain<'a>

fn new(head: &'a dyn StdError + 'static) -> Self

Trait Implementations

impl Default for Chain<'_>

fn default() -> Self

impl DoubleEndedIterator for Chain<'_>

fn next_back(&mut self) -> Option<Self::Item>

impl ExactSizeIterator for Chain<'_>

fn len(&self) -> usize

impl<'a> Clone for Chain<'a>

fn clone(&self) -> Self

impl<'a> Iterator for Chain<'a>

type Item = &'a dyn Error + 'static;
fn next(&mut self) -> Option<Self::Item>
fn size_hint(&self) -> (usize, Option<usize>)

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Chain<'a>

impl<'a> !Send for Chain<'a>

impl<'a> !Sync for Chain<'a>

impl<'a> !UnwindSafe for Chain<'a>

impl<'a> Freeze for Chain<'a>

impl<'a> Unpin for Chain<'a>

impl<'a> UnsafeUnpin for Chain<'a>

Blanket Implementations

impl<I> IntoIterator for Chain<'a> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Chain<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Chain<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Chain<'a> where T: ?Sized,

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

impl<T> CloneToUninit for Chain<'a> where T: Clone,

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

impl<T> From<T> for Chain<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Chain<'a> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Chain<'a> where U: From<T>,

fn into(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<U> for Chain<'a> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Chain<'a> where U: TryFrom<T>,

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