From 35f9ca9b0b039569724a14655047fde6a205873e 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 afd73d0ef..a31ccc0ae 100644 --- a/object/src/mem.rs +++ b/object/src/mem.rs @@ -977,15 +977,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; + }) } /// Obtain the DICOM value by finding the element @@ -1090,10 +1088,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 @@ -1141,21 +1137,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 { @@ -1164,13 +1158,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, + } + })?; } } }