Skip to content
Myr

Add example to Chain iterator

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent d159b79 · Browse files · 1 file+18 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−0 removed

  • other:+18 added−0 removed

1 file+18 added−0 removed

modified:src/error.rs+18 added
421 unmodified lines
422 }423}424425/// Iterator of a chain of source errors.426///427/// This type is the iterator returned by [`Error::chain`].428///429/// # Example430///431/// ```432/// use anyhow::Error;433/// use std::io;434///435/// pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {436/// for cause in error.chain() {437/// if let Some(io_error) = cause.downcast_ref::<io::Error>() {438/// return Some(io_error.kind());439/// }440/// }441/// None442/// }443/// ```444pub struct Chain<'a> {445 next: Option<&'a (dyn StdError + 'static)>,446}447
61 unmodified lines