diff --git a/src/error.rs b/src/error.rs index bcc8921..950167b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -423,6 +423,24 @@ impl ErrorImpl<()> { } /// 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 { +/// for cause in error.chain() { +/// if let Some(io_error) = cause.downcast_ref::() { +/// return Some(io_error.kind()); +/// } +/// } +/// None +/// } +/// ``` pub struct Chain<'a> { next: Option<&'a (dyn StdError + 'static)>, }