| 1 | #[cfg(not(feature = "std"))] |
| 2 | 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/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 3 | |
| 4 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/; |
| 5 | |
| 6 | use craterust-analyzer cargo bendy 0.6.1 crate/::state_trackerrust-analyzer cargo bendy 0.6.1 state_tracker/::{StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#, Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#}; |
| 7 | |
| 8 | /// The state of current level of the decoder |
| 9 | #[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:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 10 | enum Staterust-analyzer cargo bendy 0.6.1 state_tracker/state/State#<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>, E> { |
| 11 | /// An inner list. Allows any token |
| 12 | Seqrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Seq#, |
| 13 | /// Inside a map, expecting a key. Contains the last key read, so sorting can be validated |
| 14 | MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<S>), |
| 15 | /// Inside a map, expecting a value. Contains the last key read, so sorting can be validated |
| 16 | MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(S), |
| 17 | /// Received an error while decoding |
| 18 | Failedrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Failed#(E), |
| 19 | } |
| 20 | |
| 21 | /// Used to validate that a structure is valid |
| 22 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 23 | pub struct StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>, E = StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#> { |
| 24 | staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Staterust-analyzer cargo bendy 0.6.1 state_tracker/state/State#<S, E>>, |
| 25 | max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth.: usize, |
| 26 | } |
| 27 | |
| 28 | impl<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>, E> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#<S, E> { |
| 29 | fn defaultrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`][Default]default().() -> Selfrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`][Default] { |
| 30 | StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker# { |
| 31 | staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(2048), |
| 32 | max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth.: 2048, |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>, E> StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#<S, E> |
| 38 | where |
| 39 | S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>, |
| 40 | E: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 41 | { |
| 42 | pub fn newrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]new().() -> Selfrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`] { |
| 43 | <Selfrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`] as Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#>::defaultrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`][Default]default().() |
| 44 | } |
| 45 | |
| 46 | pub fn set_max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]set_max_depth().(&mut self, new_max_depth: usize) { |
| 47 | self.max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth. = new_max_depth |
| 48 | } |
| 49 | |
| 50 | pub fn remaining_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]remaining_depth().(&self) -> usize { |
| 51 | self.max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() |
| 52 | } |
| 53 | |
| 54 | /// Observe that an EOF was seen. This function is idempotent. |
| 55 | pub fn observe_eofrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]observe_eof().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E> { |
| 56 | self.check_errorrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]check_error().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 57 | |
| 58 | if self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 59 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 60 | } else { |
| 61 | self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::UnexpectedEofrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#UnexpectedEof#))) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | #[allow(clippy::match_same_arms)] |
| 66 | pub fn observe_tokenrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]observe_token().<'a>(&mut self, token: &Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#<'a>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E> |
| 67 | where |
| 68 | S: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a [u8]>, |
| 69 | { |
| 70 | use selfrust-analyzer cargo bendy 0.6.1 state_tracker/state/::{Staterust-analyzer cargo bendy 0.6.1 state_tracker/state/State#::*, Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::*}; |
| 71 | match (self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().(), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().token) { |
| 72 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#) => { |
| 73 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::invalid_staterust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]invalid_state().( |
| 74 | "End not allowed at top level", |
| 75 | )))); |
| 76 | }, |
| 77 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Seqrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Seq#), Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#) | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(_)), Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#) => { |
| 78 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().(); |
| 79 | }, |
| 80 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(oldlabel))), Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(label)) if oldlabel.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`&mut T`][`AsRef<U>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]ge().label => { |
| 81 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().(); |
| 82 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::UnsortedKeysrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#UnsortedKeys#))); |
| 83 | }, |
| 84 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_oldlabel))), Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(label)) => { |
| 85 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() = MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(S::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(label)); |
| 86 | }, |
| 87 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)), Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(label)) => { |
| 88 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() = MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(S::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(label)); |
| 89 | }, |
| 90 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_oldstate @ MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(_)), _tok) => { |
| 91 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::invalid_staterust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]invalid_state().( |
| 92 | "Map keys must be strings", |
| 93 | )))); |
| 94 | }, |
| 95 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(label)), Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List#) | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(label)), Dictrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Dict#) => { |
| 96 | let dummy: &[u8] = &[]; |
| 97 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() = |
| 98 | MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(label, dummy.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 99 | if self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth. { |
| 100 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::NestingTooDeeprust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#NestingTooDeep#))); |
| 101 | } |
| 102 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state. |
| 103 | .pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(if token rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List# { Seqrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Seq# } else { MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) }); |
| 104 | }, |
| 105 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_oldstate @ MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(_)), Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#) => { |
| 106 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().(); |
| 107 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::invalid_staterust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]invalid_state().( |
| 108 | "Missing map value", |
| 109 | )))); |
| 110 | }, |
| 111 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MapValuerust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapValue#(label)), _) => { |
| 112 | let dummy: &[u8] = &[]; |
| 113 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() = |
| 114 | MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(label, dummy.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 115 | }, |
| 116 | (_oldstate, Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List#) | (_oldstate, Dictrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Dict#) => { |
| 117 | if self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().self.max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#max_depth. { |
| 118 | return self.latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(E::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::NestingTooDeeprust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#NestingTooDeep#))); |
| 119 | } |
| 120 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state. |
| 121 | .pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(if token rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List# { Seqrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Seq# } else { MapKeyrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#MapKey#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) }); |
| 122 | }, |
| 123 | _ => {}, |
| 124 | } |
| 125 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 126 | } |
| 127 | |
| 128 | pub fn latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().<T>(&mut self, result: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, E>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, E> { |
| 129 | self.check_errorrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]check_error().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 130 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ref err) = result { |
| 131 | self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Staterust-analyzer cargo bendy 0.6.1 state_tracker/state/State#::Failedrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Failed#(err.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())) |
| 132 | } |
| 133 | result |
| 134 | } |
| 135 | |
| 136 | pub fn check_errorrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]check_error().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E> { |
| 137 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Staterust-analyzer cargo bendy 0.6.1 state_tracker/state/State#::Failedrust-analyzer cargo bendy 0.6.1 state_tracker/state/State#Failed#(error)) = self.staterust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#state..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() { |
| 138 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) |
| 139 | } else { |
| 140 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 141 | } |
| 142 | } |
| 143 | } |