From 26af25389acf3b7666ed08020db9ced9f0cb4036 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Tue, 28 May 2024 11:50:51 +1000 Subject: [PATCH] read: Add IndexSectionId::section_id --- src/read/index.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/read/index.rs b/src/read/index.rs index 7629a278..bd8e74bf 100644 --- a/src/read/index.rs +++ b/src/read/index.rs @@ -363,9 +363,9 @@ pub enum IndexSectionId { } impl IndexSectionId { - /// Returns the ELF section name for this kind, when found in a .dwo or .dwp file. - pub fn dwo_name(self) -> &'static str { - let section_id = match self { + /// Returns the corresponding `SectionId`. + pub fn section_id(self) -> SectionId { + match self { IndexSectionId::DebugAbbrev => SectionId::DebugAbbrev, IndexSectionId::DebugInfo => SectionId::DebugInfo, IndexSectionId::DebugLine => SectionId::DebugLine, @@ -376,8 +376,12 @@ impl IndexSectionId { IndexSectionId::DebugRngLists => SectionId::DebugRngLists, IndexSectionId::DebugStrOffsets => SectionId::DebugStrOffsets, IndexSectionId::DebugTypes => SectionId::DebugTypes, - }; - section_id.dwo_name().unwrap() + } + } + + /// Returns the ELF section name for this kind, when found in a .dwo or .dwp file. + pub fn dwo_name(self) -> &'static str { + self.section_id().dwo_name().unwrap() } }