From b09f50e6c1484b293835f9d9ecc0a755bd3c718b Mon Sep 17 00:00:00 2001 From: just-an-engineer Date: Sat, 7 Sep 2024 15:31:56 -0400 Subject: [PATCH] Use MAIN_SERPARATOR over manual conditional variable assignment --- src/uu/rm/src/rm.rs | 5 +---- tests/by-util/test_rm.rs | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 44e8c247edc..a195ea7bb97 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -326,10 +326,7 @@ pub fn remove(files: &[&OsStr], options: &Options) -> bool { fn handle_dir(path: &Path, options: &Options) -> bool { let mut had_err = false; - #[cfg(unix)] - let del = "/"; - #[cfg(windows)] - let del = "\\"; + let del = std::path::MAIN_SEPARATOR; if path .to_str() diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 75fb84bfd71..3ddb99015b9 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -718,10 +718,7 @@ fn test_non_utf8() { fn test_rm_no_del_parent() { let (at, mut ucmd) = at_and_ucmd!(); - #[cfg(not(windows))] - let del = "/"; - #[cfg(windows)] - let del = "\\"; + let del = std::path::MAIN_SEPARATOR; at.mkdir("test"); at.mkdir(&format!("test{del}dir")); @@ -736,10 +733,7 @@ fn test_rm_no_del_parent() { fn test_rm_no_del_cur() { let (at, mut ucmd) = at_and_ucmd!(); - #[cfg(not(windows))] - let del = "/"; - #[cfg(windows)] - let del = "\\"; + let del = std::path::MAIN_SEPARATOR; at.mkdir("test"); at.touch(&format!("test{del}file"));