Skip to content

Commit

Permalink
MAIN: and_then -> map, run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
naterichman authored and Enet4 committed Apr 11, 2024
1 parent 6828b2f commit 35f9ca9
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions object/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,15 +977,13 @@ where
pub fn update_value_at(
&mut self,
selector: impl Into<AttributeSelector>,
f: impl FnMut(&mut Value<InMemDicomObject<D>, InMemFragment>)
f: impl FnMut(&mut Value<InMemDicomObject<D>, 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
}
})?;
}
}
}
Expand Down

0 comments on commit 35f9ca9

Please sign in to comment.