Skip to content
Myr

Add example of Error::chain

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 896dd7a · Browse files · 1 file+16 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+16 added−0 removed

  • other:+16 added−0 removed

1 file+16 added−0 removed

modified:src/error.rs+16 added
163 unmodified lines
164 ///165 /// This iterator will visit every error in the cause chain of this error166 /// object, beginning with the error that this error object was created167 /// from.168 ///169 /// # Example170 ///171 /// ```172 /// use anyhow::Error;173 /// use std::io;174 ///175 /// pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {176 /// for cause in error.chain() {177 /// if let Some(io_error) = cause.downcast_ref::<io::Error>() {178 /// return Some(io_error.kind());179 /// }180 /// }181 /// None182 /// }183 /// ```184 pub fn chain(&self) -> Chain {185 Chain {186 next: Some(self.inner.error()),187 }
303 unmodified lines