Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use ? instead of try! #60

Merged
merged 1 commit into from Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dynamic.rs
Expand Up @@ -63,7 +63,7 @@ macro_rules! impls {
}

pub fn get_val(&self) -> Result<$p, &'static str> {
match try!(self.get_tag()) {
match self.get_tag()? {
Tag::Needed | Tag::PltRelSize | Tag::RelaSize | Tag::RelaEnt | Tag::StrSize |
Tag::SymEnt | Tag::SoName | Tag::RPath | Tag::RelSize | Tag::RelEnt | Tag::PltRel |
Tag::InitArraySize | Tag::FiniArraySize | Tag::RunPath | Tag::Flags |
Expand All @@ -74,7 +74,7 @@ macro_rules! impls {
}

pub fn get_ptr(&self) -> Result<$p, &'static str> {
match try!(self.get_tag()) {
match self.get_tag()? {
Tag::Pltgot | Tag::Hash | Tag::StrTab | Tag::SymTab | Tag::Rela | Tag::Init | Tag::Fini |
Tag::Rel | Tag::Debug | Tag::JmpRel | Tag::InitArray | Tag::FiniArray |
Tag::PreInitArray | Tag::SymTabShIndex | Tag::OsSpecific(_) | Tag::ProcessorSpecific(_)
Expand Down
18 changes: 9 additions & 9 deletions src/program.rs
Expand Up @@ -176,15 +176,15 @@ macro_rules! ph_impl {

impl fmt::Display for $ph {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(writeln!(f, "Program header:"));
try!(writeln!(f, " type: {:?}", self.get_type()));
try!(writeln!(f, " flags: {}", self.flags));
try!(writeln!(f, " offset: {:#x}", self.offset));
try!(writeln!(f, " virtual address: {:#x}", self.virtual_addr));
try!(writeln!(f, " physical address: {:#x}", self.physical_addr));
try!(writeln!(f, " file size: {:#x}", self.file_size));
try!(writeln!(f, " memory size: {:#x}", self.mem_size));
try!(writeln!(f, " align: {:#x}", self.align));
writeln!(f, "Program header:")?;
writeln!(f, " type: {:?}", self.get_type())?;
writeln!(f, " flags: {}", self.flags)?;
writeln!(f, " offset: {:#x}", self.offset)?;
writeln!(f, " virtual address: {:#x}", self.virtual_addr)?;
writeln!(f, " physical address: {:#x}", self.physical_addr)?;
writeln!(f, " file size: {:#x}", self.file_size)?;
writeln!(f, " memory size: {:#x}", self.mem_size)?;
writeln!(f, " align: {:#x}", self.align)?;
Ok(())
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/sections.rs
Expand Up @@ -223,16 +223,16 @@ impl<'a> fmt::Display for SectionHeader<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
macro_rules! sh_display {
($sh: ident) => {{
try!(writeln!(f, "Section header:"));
try!(writeln!(f, " name: {:?}", $sh.name));
try!(writeln!(f, " type: {:?}", self.get_type()));
try!(writeln!(f, " flags: {:?}", $sh.flags));
try!(writeln!(f, " address: {:?}", $sh.address));
try!(writeln!(f, " offset: {:?}", $sh.offset));
try!(writeln!(f, " size: {:?}", $sh.size));
try!(writeln!(f, " link: {:?}", $sh.link));
try!(writeln!(f, " align: {:?}", $sh.align));
try!(writeln!(f, " entry size: {:?}", $sh.entry_size));
writeln!(f, "Section header:")?;
writeln!(f, " name: {:?}", $sh.name)?;
writeln!(f, " type: {:?}", self.get_type())?;
writeln!(f, " flags: {:?}", $sh.flags)?;
writeln!(f, " address: {:?}", $sh.address)?;
writeln!(f, " offset: {:?}", $sh.offset)?;
writeln!(f, " size: {:?}", $sh.size)?;
writeln!(f, " link: {:?}", $sh.link)?;
writeln!(f, " align: {:?}", $sh.align)?;
writeln!(f, " entry size: {:?}", $sh.entry_size)?;
Ok(())
}}
}
Expand Down