Skip to content
Myr

Add a Chain::new constructor

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 2c88164 · Browse files · 2 files+9 added−6 removed
This commit

State

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

Diff stats

2 files+9 added−6 removed

  • other:+9 added−6 removed

2 files+9 added−6 removed

modified:src/chain.rs+8 added
11 unmodified lines
12 rest: vec::IntoIter<&'a (dyn StdError + 'static)>,13 },14}1516impl<'a> Chain<'a> {17 pub fn new(head: &'a (dyn StdError + 'static)) -> Self {18 Chain {19 state: ChainState::Linked { next: Some(head) },20 }21 }22}2324impl<'a> Iterator for Chain<'a> {25 type Item = &'a (dyn StdError + 'static);2627 fn next(&mut self) -> Option<Self::Item> {
50 unmodified lines
modified:src/error.rs+1 added-6 removed
1use crate::backtrace::Backtrace;2use crate::chain::ChainState;2use crate::{Chain, Error};3use std::any::TypeId;4use std::error::Error as StdError;5use std::fmt::{self, Debug, Display};
714 unmodified lines
720 .expect("backtrace capture failed")721 }722723 pub(crate) fn chain(&self) -> Chain {725 Chain {726 state: ChainState::Linked {727 next: Some(self.error()),728 },729 }724 Chain::new(self.error())725 }726}727728impl<E> StdError for ErrorImpl<E>
64 unmodified lines