From 5eabab9a29057c84b63896ad2dfa6e9cbba5b243 Mon Sep 17 00:00:00 2001 From: Joshua Klein Date: Fri, 23 Aug 2024 17:15:05 -0400 Subject: [PATCH] Fix: port #5 to all other reader types --- src/io/mzml/async.rs | 3 +-- src/io/mzml/reader.rs | 3 +-- src/io/mzmlb/reader.rs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/io/mzml/async.rs b/src/io/mzml/async.rs index 428e640..2e45ab7 100644 --- a/src/io/mzml/async.rs +++ b/src/io/mzml/async.rs @@ -741,8 +741,7 @@ impl< /// Retrieve a spectrum by it's native ID pub async fn get_spectrum_by_id(&mut self, id: &str) -> Option> { - let offset_ref = self.index.get(id); - let offset = offset_ref.expect("Failed to retrieve offset"); + let offset = self.index.get(id)?; let start = self .handle .stream_position() diff --git a/src/io/mzml/reader.rs b/src/io/mzml/reader.rs index 83f7262..0ba7258 100644 --- a/src/io/mzml/reader.rs +++ b/src/io/mzml/reader.rs @@ -1553,8 +1553,7 @@ impl< { /// Retrieve a spectrum by it's native ID fn get_spectrum_by_id(&mut self, id: &str) -> Option> { - let offset_ref = self.spectrum_index.get(id); - let offset = offset_ref.expect("Failed to retrieve offset"); + let offset = self.spectrum_index.get(id)?; let start = self .handle .stream_position() diff --git a/src/io/mzmlb/reader.rs b/src/io/mzmlb/reader.rs index 8e55351..30d9c39 100644 --- a/src/io/mzmlb/reader.rs +++ b/src/io/mzmlb/reader.rs @@ -1082,8 +1082,7 @@ impl< { /// Retrieve a spectrum by it's native ID fn get_spectrum_by_id(&mut self, id: &str) -> Option> { - let offset_ref = self.spectrum_index.get(id); - let offset = offset_ref.expect("Failed to retrieve offset"); + let offset = self.spectrum_index.get(id)?; let start = self .mzml_parser .stream_position()