| 1 | use selfrust-analyzer cargo anyhow 1.0.103 chain/::ChainStaterust-analyzer cargo anyhow 1.0.103 chain/ChainState#::*; |
| 2 | use craterust-analyzer cargo anyhow 1.0.103 crate/::StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 3 | |
| 4 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 5 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#}; |
| 6 | |
| 7 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 8 | pub(craterust-analyzer cargo anyhow 1.0.103 crate/) use craterust-analyzer cargo anyhow 1.0.103 crate/::Chainrust-analyzer cargo anyhow 1.0.103 Chain#; |
| 9 | |
| 10 | #[cfg(all(not(feature = "std"), anyhow_no_core_error))] |
| 11 | pub(craterust-analyzer cargo anyhow 1.0.103 crate/) struct Chain<'a> { |
| 12 | state: ChainStaterust-analyzer cargo anyhow 1.0.103 chain/ChainState#<'a>, |
| 13 | } |
| 14 | |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 16 | pub(craterust-analyzer cargo anyhow 1.0.103 crate/) enum ChainStaterust-analyzer cargo anyhow 1.0.103 chain/ChainState#<'a> { |
| 17 | Linkedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked# { |
| 18 | nextrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked#next.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)>, |
| 19 | }, |
| 20 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 21 | Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { |
| 22 | restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/IntoIter#<&'a (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)>, |
| 23 | }, |
| 24 | } |
| 25 | |
| 26 | impl<'a> Chainrust-analyzer cargo anyhow 1.0.103 Chain#<'a> { |
| 27 | #[cold] |
| 28 | pub fn newrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`]new().(head: &'a (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)) -> Selfrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`] { |
| 29 | Chainrust-analyzer cargo anyhow 1.0.103 Chain# { |
| 30 | staterust-analyzer cargo anyhow 1.0.103 Chain#state.: ChainStaterust-analyzer cargo anyhow 1.0.103 chain/ChainState#::Linkedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked# { nextrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked#next.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(head) }, |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Chainrust-analyzer cargo anyhow 1.0.103 Chain#<'a> { |
| 36 | type Itemrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`][Iterator]Item# = &'a (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static); |
| 37 | |
| 38 | fn nextrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 39 | match &mut self.staterust-analyzer cargo anyhow 1.0.103 Chain#state. { |
| 40 | Linkedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked# { nextrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked#next. } => { |
| 41 | let error = (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().next)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 42 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().next = error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().(); |
| 43 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error) |
| 44 | } |
| 45 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 46 | Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest. } => rest.nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().(), |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | fn size_hintrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 51 | let len = self.lenrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][ExactSizeIterator]len().(); |
| 52 | (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len)) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 57 | impl DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Chainrust-analyzer cargo anyhow 1.0.103 Chain#<'_> { |
| 58 | fn next_backrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 59 | match &mut self.staterust-analyzer cargo anyhow 1.0.103 Chain#state. { |
| 60 | Linkedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked# { mut nextrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked#next. } => { |
| 61 | let mut rest = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 62 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cause) = next { |
| 63 | next = cause.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().(); |
| 64 | rest.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(cause); |
| 65 | } |
| 66 | let mut rest = rest.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(); |
| 67 | let last = rest.next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][DoubleEndedIterator]next_back().(); |
| 68 | self.staterust-analyzer cargo anyhow 1.0.103 Chain#state. = Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest. }; |
| 69 | last |
| 70 | } |
| 71 | Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest. } => rest.next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][DoubleEndedIterator]next_back().(), |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | impl ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for Chainrust-analyzer cargo anyhow 1.0.103 Chain#<'_> { |
| 77 | fn lenrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][ExactSizeIterator]len().(&self) -> usize { |
| 78 | match &self.staterust-analyzer cargo anyhow 1.0.103 Chain#state. { |
| 79 | Linkedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked# { mut nextrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Linked#next. } => { |
| 80 | let mut len = 0; |
| 81 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cause) = next { |
| 82 | next = cause.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().(); |
| 83 | len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 84 | } |
| 85 | len |
| 86 | } |
| 87 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 88 | Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest. } => rest.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#len().(), |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
| 94 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Chainrust-analyzer cargo anyhow 1.0.103 Chain#<'_> { |
| 95 | fn defaultrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][Default]default().() -> Selfrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'_>`][Default] { |
| 96 | Chainrust-analyzer cargo anyhow 1.0.103 Chain# { |
| 97 | staterust-analyzer cargo anyhow 1.0.103 Chain#state.: ChainStaterust-analyzer cargo anyhow 1.0.103 chain/ChainState#::Bufferedrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered# { |
| 98 | restrust-analyzer cargo anyhow 1.0.103 chain/ChainState#Buffered#rest.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().().into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 99 | }, |
| 100 | } |
| 101 | } |
| 102 | } |