about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 9b4a3270f28..a5e82c31d79 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -508,6 +508,14 @@ impl WindowsPath {
             }
         }
     }
+
+    /// Execute a function on p as well as all of its ancestors
+    pub fn each_parent(&self, f: &fn(&Path)) {
+        if !self.components.is_empty() {
+            f(self);
+            self.pop().each_parent(f);
+        }
+    }
 }
 
 impl ToStr for PosixPath {