Skip to content

Commit

Permalink
Simplify expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
kkent030315 committed Oct 31, 2024
1 parent 2d74eda commit 7cda493
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/pe/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::error;
use alloc::string::String;
use alloc::vec::Vec;
use core::fmt;
use core::ops::Not;
use log::debug;
use scroll::{Pread, Pwrite, SizeWith};

Expand Down Expand Up @@ -303,11 +304,7 @@ impl ResourceEntry {
/// - [`RT_HTML`]
/// - [`RT_MANIFEST`]
pub fn id(&self) -> Option<u16> {
if !self.name_is_string() {
Some(self.name_or_id as u16)
} else {
None
}
self.name_is_string().not().then(|| self.name_or_id as u16)
}

/// Checks if the resource entry points to a directory.
Expand All @@ -328,11 +325,9 @@ impl ResourceEntry {
///
/// Returns `Some(u32)` if the resource entry points to data, otherwise `None`.
pub fn offset_to_data(&self) -> Option<u32> {
if !self.data_is_directory() {
Some(self.offset_to_data_or_directory)
} else {
None
}
self.data_is_directory()
.not()
.then(|| self.offset_to_data_or_directory)
}

/// Returns the next depth entry of [`ResourceEntry`] if present
Expand Down

0 comments on commit 7cda493

Please sign in to comment.