From 4ab35717ac1755554977108327aaac7476c19ff1 Mon Sep 17 00:00:00 2001 From: Nate Richman Date: Sat, 16 Mar 2024 09:17:41 -0500 Subject: [PATCH] MAIN: and_then -> map, run rustfmt --- object/src/mem.rs | 53 ++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/object/src/mem.rs b/object/src/mem.rs index 3fb5c9ba0..fe6d6cc8c 100644 --- a/object/src/mem.rs +++ b/object/src/mem.rs @@ -978,15 +978,13 @@ where pub fn update_value_at( &mut self, selector: impl Into, - f: impl FnMut(&mut Value, InMemFragment>) + f: impl FnMut(&mut Value, InMemFragment>), ) -> Result<(), AtAccessError> { - self.entry_at_mut(selector).map(|e| { - e.update_value(f) - }) - .and_then(|_| { - self.len = Length::UNDEFINED; - Ok(()) - }) + self.entry_at_mut(selector) + .map(|e| e.update_value(f)) + .map(|_| { + self.len = Length::UNDEFINED; + }) } /// Get a DataElement by AttributeSelector @@ -1008,10 +1006,8 @@ where match step { // reached the leaf AttributeSelectorStep::Tag(tag) => { - return obj.get(*tag).with_context(|| { - MissingLeafElementSnafu { - selector: selector.clone(), - } + return obj.get(*tag).with_context(|| MissingLeafElementSnafu { + selector: selector.clone(), }) } // navigate further down @@ -1059,21 +1055,19 @@ where match step { // reached the leaf AttributeSelectorStep::Tag(tag) => { - return obj.get_mut(*tag).with_context(|| { - MissingLeafElementSnafu { - selector: selector.clone(), - } + return obj.get_mut(*tag).with_context(|| MissingLeafElementSnafu { + selector: selector.clone(), }) } // navigate further down AttributeSelectorStep::Nested { tag, item } => { - let e = obj - .entries - .get_mut(tag) - .with_context(|| crate::MissingSequenceSnafu { - selector: selector.clone(), - step_index: i as u32, - })?; + let e = + obj.entries + .get_mut(tag) + .with_context(|| crate::MissingSequenceSnafu { + selector: selector.clone(), + step_index: i as u32, + })?; // get items let items = e.items_mut().with_context(|| NotASequenceSnafu { @@ -1082,13 +1076,12 @@ where })?; // if item.length == i and action is a constructive action, append new item - obj = - items - .get_mut(*item as usize) - .with_context(|| crate::MissingSequenceSnafu { - selector: selector.clone(), - step_index: i as u32, - })?; + obj = items.get_mut(*item as usize).with_context(|| { + crate::MissingSequenceSnafu { + selector: selector.clone(), + step_index: i as u32, + } + })?; } } }