From d18839f3dcf7d599dc96f8ee36627d7b97d234b8 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Tue, 28 Aug 2018 23:27:34 +0100 Subject: ignore: add into_path for DirEntry (#1031) This commit adds ignore::DirEntry::into_path to match the corresponding method on walkdir::DirEntry. --- ignore/src/walk.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ignore') diff --git a/ignore/src/walk.rs b/ignore/src/walk.rs index 2f54b53f..bded1e1c 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 } -- cgit v1.2.3