Skip to content

Commit

Permalink
[parser] [object] Revert use of inspect method for more Rust compiler…
Browse files Browse the repository at this point in the history
… compatibility

- Result::inspect and Option::inspect were introduced in 1.76.0
  • Loading branch information
Enet4 committed Oct 30, 2024
1 parent 9688a97 commit f153093
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions object/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,19 +940,21 @@ where
/// reporting whether it was present.
pub fn remove_element_by_name(&mut self, name: &str) -> Result<bool, AccessByNameError> {
let tag = self.lookup_name(name)?;
Ok(self.entries.remove(&tag).is_some()).inspect(|&removed| {
Ok(self.entries.remove(&tag).is_some()).map(|removed| {

Check warning on line 943 in object/src/mem.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

using `map` over `inspect`
if removed {
self.len = Length::UNDEFINED;
}
removed
})
}

/// Remove and return a particular DICOM element by its tag.
pub fn take_element(&mut self, tag: Tag) -> Result<InMemElement<D>> {
self.entries
.remove(&tag)
.inspect(|_| {
.map(|e| {

Check warning on line 955 in object/src/mem.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

using `map` over `inspect`
self.len = Length::UNDEFINED;
e
})
.context(NoSuchDataElementTagSnafu { tag })
}
Expand All @@ -961,8 +963,9 @@ where
/// if it is present,
/// returns `None` otherwise.
pub fn take(&mut self, tag: Tag) -> Option<InMemElement<D>> {
self.entries.remove(&tag).inspect(|_| {
self.entries.remove(&tag).map(|e| {

Check warning on line 966 in object/src/mem.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

using `map` over `inspect`
self.len = Length::UNDEFINED;
e
})
}

Expand All @@ -974,8 +977,9 @@ where
let tag = self.lookup_name(name)?;
self.entries
.remove(&tag)
.inspect(|_| {
.map(|e| {

Check warning on line 980 in object/src/mem.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

using `map` over `inspect`
self.len = Length::UNDEFINED;
e
})
.with_context(|| NoSuchDataElementAliasSnafu {
tag,
Expand Down
3 changes: 2 additions & 1 deletion parser/src/stateful/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,9 @@ where
.context(DecodeItemHeaderSnafu {
position: self.position,
})
.inspect(|_| {
.map(|header| {

Check warning on line 916 in parser/src/stateful/decode.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

using `map` over `inspect`
self.position += 8;
header
})
.map_err(From::from)
}
Expand Down

0 comments on commit f153093

Please sign in to comment.