mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-29 05:52:13 +00:00
Add a Chain::new constructor
This commit is contained in:
parent
2c88164b5b
commit
ca2b8b9bb0
@ -13,6 +13,14 @@ pub(crate) enum ChainState<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
impl<'a> Chain<'a> {
|
||||
pub fn new(head: &'a (dyn StdError + 'static)) -> Self {
|
||||
Chain {
|
||||
state: ChainState::Linked { next: Some(head) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for Chain<'a> {
|
||||
type Item = &'a (dyn StdError + 'static);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::backtrace::Backtrace;
|
||||
use crate::chain::ChainState;
|
||||
use crate::{Chain, Error};
|
||||
use std::any::TypeId;
|
||||
use std::error::Error as StdError;
|
||||
@ -722,11 +721,7 @@ impl ErrorImpl<()> {
|
||||
}
|
||||
|
||||
pub(crate) fn chain(&self) -> Chain {
|
||||
Chain {
|
||||
state: ChainState::Linked {
|
||||
next: Some(self.error()),
|
||||
},
|
||||
}
|
||||
Chain::new(self.error())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user