Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 7, 2025
1 parent f190489 commit eaebfa9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ fn debug_filename(path: &Path) -> PathBuf {
pub(crate) fn is_dynamic_library_filename(path: &Path) -> bool {
path.file_name()
.and_then(|f| f.to_str())
.map_or(false, |f| f.ends_with(DLL_SUFFIX))
.is_some_and(|f| f.ends_with(DLL_SUFFIX))
}

/// Compress man pages and other assets per Debian Policy.
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl Config {
log::debug!("building workspace because {} is from another package", source_path.unwrap_or(&asset_target.target_path).display());
same_package = false;
}
if asset_target.is_dynamic_library() || source_path.map_or(false, is_dynamic_library_filename) {
if asset_target.is_dynamic_library() || source_path.is_some_and(is_dynamic_library_filename) {
log::debug!("building libs for {}", source_path.unwrap_or(&asset_target.target_path).display());
build_libs = true;
} else if asset_target.is_executable() {
Expand Down
3 changes: 1 addition & 2 deletions src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ pub fn strip_binaries(config: &mut Config, package_deb: &mut PackageConfig, rust
return Err(CargoDebError::StripFailed(path.to_owned(), "The file doesn't exist".into()));
}

let conf_path = cargo_config.as_ref().map(|c| c.path())
.unwrap_or_else(|| Path::new(".cargo/config"));
let conf_path = cargo_config.as_ref().map_or(Path::new(".cargo/config"), |c| c.path());
let file_name = path.file_stem().ok_or(CargoDebError::Str("bad path"))?.to_string_lossy();
let stripped_temp_path = stripped_binaries_output_dir.join(format!("{file_name}.tmp{i}-stripped"));
let _ = fs::remove_file(&stripped_temp_path);
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() -> ExitCode {
let install = matches.get_flag("install");

let compress_type = match matches.get_one::<String>("compress-type").map(|s| s.as_str()) {
Some("gz") | Some("gzip") => Format::Gzip,
Some("gz" | "gzip") => Format::Gzip,
Some("xz") | None => Format::Xz,
_ => {
print_error(&CargoDebError::Str("unrecognized compression format. Supported: gzip, xz"));
Expand Down Expand Up @@ -89,7 +89,7 @@ fn main() -> ExitCode {
let deb_version = matches.get_one::<String>("deb-version").cloned();
let deb_revision = matches.get_one::<String>("deb-revision").cloned();

if deb_version.is_some() && deb_revision.as_deref().map_or(false, |r| !r.is_empty()) {
if deb_version.is_some() && deb_revision.as_deref().is_some_and(|r| !r.is_empty()) {
listener.warning(format!("--deb-version takes precedence over --deb-revision. Revision '{}' will be ignored", deb_revision.as_deref().unwrap_or_default()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod compress;
/// Note: Due to the way the Path type works the final component is returned
/// even if it looks like a directory, e.g. "/some/dir/" will return "dir"...
pub(crate) fn fname_from_path(path: &Path) -> Option<String> {
if path.to_bytes().ends_with(&[b'/']) {
if path.to_bytes().ends_with(b"/") {
return None;
}
let path = path.file_name()?.to_string_lossy();
Expand Down

0 comments on commit eaebfa9

Please sign in to comment.