Skip to content

Commit

Permalink
Merge branch 'master' into custom_error_type
Browse files Browse the repository at this point in the history
  • Loading branch information
toku-sa-n authored Jul 8, 2021
2 parents c6ca804 + 3f6df1d commit 9879f56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 3 additions & 7 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub enum Class {

impl Class {
pub fn is_none(&self) -> bool {
if let Class::None = *self { true } else { false }
matches!(*self, Class::None)
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ pub enum Data {

impl Data {
pub fn is_none(&self) -> bool {
if let Data::None = *self { true } else { false }
matches!(*self, Data::None)
}
}

Expand Down Expand Up @@ -301,11 +301,7 @@ pub enum Version {

impl Version {
pub fn is_none(&self) -> bool {
if let Version::None = *self {
true
} else {
false
}
matches!(*self, Version::None)
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ pub struct ElfFile<'a> {

impl<'a> ElfFile<'a> {
pub fn new(input: &'a [u8]) -> Result<ElfFile<'a>, Error> {
let header = header::parse_header(input)?;
Ok(ElfFile {
input,
header,
})
header::parse_header(input).map(|header| ElfFile {input, header})
}

pub fn section_header(&self, index: u16) -> Result<SectionHeader<'a>, Error> {
Expand Down

0 comments on commit 9879f56

Please sign in to comment.