diff --git a/ignore/src/walk.rs b/ignore/src/walk.rs index 2f54b53..bded1e1 100644 --- a/ignore/src/walk.rs +++ b/ignore/src/walk.rs @@ -36,6 +36,14 @@ impl DirEntry { self.dent.path() } + /// The full path that this entry represents. + /// Analogous to [`path`], but moves ownership of the path. + /// + /// [`path`]: struct.DirEntry.html#method.path + pub fn into_path(self) -> PathBuf { + self.dent.into_path() + } + /// Whether this entry corresponds to a symbolic link or not. pub fn path_is_symlink(&self) -> bool { self.dent.path_is_symlink() @@ -144,6 +152,15 @@ impl DirEntryInner { } } + fn into_path(self) -> PathBuf { + use self::DirEntryInner::*; + match self { + Stdin => PathBuf::from(""), + Walkdir(x) => x.into_path(), + Raw(x) => x.into_path(), + } + } + fn path_is_symlink(&self) -> bool { use self::DirEntryInner::*; match *self { @@ -262,6 +279,10 @@ impl DirEntryRaw { &self.path } + fn into_path(self) -> PathBuf { + self.path + } + fn path_is_symlink(&self) -> bool { self.ty.is_symlink() || self.follow_link }