[][src]Struct jane_eyre::eyre::Chain

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

Iterator of a chain of source errors.

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

Example

use eyre::Report;
use std::io;

pub fn underlying_io_error_kind(error: &Report) -> 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>[src]

pub fn new(head: &'a (dyn Error + 'static)) -> Chain<'a>[src]

Construct an iterator over a chain of errors via the source method

Example

use std::error::Error;
use std::fmt::{self, Write};
use eyre::Chain;
use indenter::indented;

fn report(error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>) -> fmt::Result {
    let mut errors = Chain::new(error).enumerate();
    for (i, error) in errors {
        writeln!(f)?;
        write!(indented(f).ind(i), "{}", error)?;
    }

    Ok(())
}

Trait Implementations

impl<'a> Clone for Chain<'a>[src]

impl<'_> Default for Chain<'_>[src]

impl<'_> DoubleEndedIterator for Chain<'_>[src]

impl<'_> ExactSizeIterator for Chain<'_>[src]

impl<'a> Iterator for Chain<'a>[src]

type Item = &'a (dyn Error + 'static)

The type of the elements being iterated over.

Auto Trait Implementations

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>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.