about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMichael Hall <michael@mbh.sh>2021-08-17 12:24:28 +1000
committerMichael Hall <michael@mbh.sh>2021-08-17 12:26:24 +1000
commit51cf318dbcdd38d6a7478413513a72097d9622c3 (patch)
tree439e8d28b261e02683b136d30f0b266149f8a3f9 /library/std/src
parent1e759bef919e3600481839324ba02c637ec13ee1 (diff)
downloadrust-51cf318dbcdd38d6a7478413513a72097d9622c3.tar.gz
rust-51cf318dbcdd38d6a7478413513a72097d9622c3.zip
remove unnecessary empty check
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/path.rs4
-rw-r--r--library/std/src/path/tests.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 9ab2f045d69..8a2450fcb88 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2217,9 +2217,7 @@ impl Path {
     ///
     #[unstable(feature = "path_file_prefix", issue = "86319")]
     pub fn file_prefix(&self) -> Option<&OsStr> {
-        self.file_name()
-            .map(split_file_at_dot)
-            .and_then(|(before, after)| if before.is_empty() { after } else { Some(before) })
+        self.file_name().map(split_file_at_dot).and_then(|(before, _after)| Some(before))
     }
 
     /// Extracts the extension of [`self.file_name`], if possible.
diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs
index d7ba4789391..e8b960e6d73 100644
--- a/library/std/src/path/tests.rs
+++ b/library/std/src/path/tests.rs
@@ -1127,6 +1127,8 @@ pub fn test_stem_ext() {
 
     t!(".x.y.z", file_stem: Some(".x.y"), extension: Some("z"));
 
+    t!("..x.y.z", file_stem: Some("..x.y"), extension: Some("z"));
+
     t!("", file_stem: None, extension: None);
 }
 
@@ -1168,6 +1170,8 @@ pub fn test_prefix_ext() {
 
     t!(".x.y.z", file_prefix: Some(".x"), extension: Some("z"));
 
+    t!("..x.y.z", file_prefix: Some("."), extension: Some("z"));
+
     t!("", file_prefix: None, extension: None);
 }