diff options
author | Aaron Power <Aaronepower@users.noreply.github.com> | 2018-08-28 23:27:34 +0100 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-08-28 18:27:34 -0400 |
commit | d18839f3dcf7d599dc96f8ee36627d7b97d234b8 (patch) | |
tree | 5979e43fbfffb25675cc8b0f8b2d4f0780879e6f | |
parent | 8f978a3cf798b9652653f3bfc0eb637112070fca (diff) |
ignore: add into_path for DirEntry (#1031)
This commit adds ignore::DirEntry::into_path to match
the corresponding method on walkdir::DirEntry.
-rw-r--r-- | ignore/src/walk.rs | 21 |
1 files changed, 21 insertions, 0 deletions
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("<stdin>"), + 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 } |