From f153093e5ad4529cce31feece07e1376727c4c62 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Wed, 30 Oct 2024 22:08:44 +0000 Subject: [PATCH] [parser] [object] Revert use of inspect method for more Rust compiler compatibility - Result::inspect and Option::inspect were introduced in 1.76.0 --- object/src/mem.rs | 12 ++++++++---- parser/src/stateful/decode.rs | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/object/src/mem.rs b/object/src/mem.rs index 5607d792..9cdd8ff6 100644 --- a/object/src/mem.rs +++ b/object/src/mem.rs @@ -940,10 +940,11 @@ where /// reporting whether it was present. pub fn remove_element_by_name(&mut self, name: &str) -> Result { let tag = self.lookup_name(name)?; - Ok(self.entries.remove(&tag).is_some()).inspect(|&removed| { + Ok(self.entries.remove(&tag).is_some()).map(|removed| { if removed { self.len = Length::UNDEFINED; } + removed }) } @@ -951,8 +952,9 @@ where pub fn take_element(&mut self, tag: Tag) -> Result> { self.entries .remove(&tag) - .inspect(|_| { + .map(|e| { self.len = Length::UNDEFINED; + e }) .context(NoSuchDataElementTagSnafu { tag }) } @@ -961,8 +963,9 @@ where /// if it is present, /// returns `None` otherwise. pub fn take(&mut self, tag: Tag) -> Option> { - self.entries.remove(&tag).inspect(|_| { + self.entries.remove(&tag).map(|e| { self.len = Length::UNDEFINED; + e }) } @@ -974,8 +977,9 @@ where let tag = self.lookup_name(name)?; self.entries .remove(&tag) - .inspect(|_| { + .map(|e| { self.len = Length::UNDEFINED; + e }) .with_context(|| NoSuchDataElementAliasSnafu { tag, diff --git a/parser/src/stateful/decode.rs b/parser/src/stateful/decode.rs index 1e5d8dd6..c0a20704 100644 --- a/parser/src/stateful/decode.rs +++ b/parser/src/stateful/decode.rs @@ -913,8 +913,9 @@ where .context(DecodeItemHeaderSnafu { position: self.position, }) - .inspect(|_| { + .map(|header| { self.position += 8; + header }) .map_err(From::from) }