From d600601162d8a28b0a7e4eeaba81d0c2cee2e226 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Fri, 28 Jun 2013 08:51:31 -0400 Subject: [PATCH] Add each_parent to WindowsPath --- src/libstd/path.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 {