Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/paths/src/lib.rs')
-rw-r--r--crates/paths/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs
index ac09121aed..083dfcf43d 100644
--- a/crates/paths/src/lib.rs
+++ b/crates/paths/src/lib.rs
@@ -184,6 +184,13 @@ impl AbsPath {
self.0.ends_with(&suffix.0)
}
+ pub fn name_and_extension(&self) -> Option<(&str, Option<&str>)> {
+ Some((
+ self.file_stem()?.to_str()?,
+ self.extension().and_then(|extension| extension.to_str()),
+ ))
+ }
+
// region:delegate-methods
// Note that we deliberately don't implement `Deref<Target = Path>` here.