Struct Chain

struct Chain<'a> { ... }

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> crate::Chain<'a>

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

impl Default for crate::Chain<'_>

fn default() -> Self

impl DoubleEndedIterator for crate::Chain<'_>

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

impl ExactSizeIterator for crate::Chain<'_>

fn len(self: &Self) -> usize

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

fn clone(self: &Self) -> Chain<'a>

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

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

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

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

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

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

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

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

impl<I> IntoIterator for Chain<'a>

fn into_iter(self: Self) -> I

impl<T> Any for Chain<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Chain<'a>

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

impl<T> BorrowMut for Chain<'a>

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

impl<T> CloneToUninit for Chain<'a>

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

impl<T> From for Chain<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Chain<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Chain<'a>

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>

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

impl<T, U> TryInto for Chain<'a>

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