Skip to content

Commit

Permalink
sam/header/parser: Keep existing record in header on a duplicate ID e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
zaeleus committed Dec 20, 2024
1 parent 31d9b0b commit f2edbb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions noodles-sam/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

This can be used to read the raw SAM header.

### Changed

* sam/header/parser: Keep existing record in header on a duplicate ID error.

## 0.67.0 - 2024-12-12

### Changed
Expand Down
7 changes: 2 additions & 5 deletions noodles-sam/src/header/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn extract_version(src: &[u8]) -> Option<Version> {

fn try_insert<K, V, F, E>(map: &mut IndexMap<K, V>, key: K, value: V, f: F) -> Result<(), E>
where
K: Hash + Eq,
K: Hash + Eq + Clone,
F: FnOnce(K) -> E,
{
use indexmap::map::Entry;
Expand All @@ -180,10 +180,7 @@ where
e.insert(value);
Ok(())
}
Entry::Occupied(e) => {
let (k, _) = e.swap_remove_entry();
Err(f(k))
}
Entry::Occupied(e) => Err(f(e.key().clone())),
}
}

Expand Down

0 comments on commit f2edbb2

Please sign in to comment.