mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
remove unnecessary empty check
This commit is contained in:
parent
1e759bef91
commit
51cf318dbc
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user