1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-03-03 14:32:22 +02:00

ignore: add into_path for DirEntry (#1031)

This commit adds ignore::DirEntry::into_path to match
the corresponding method on walkdir::DirEntry.
This commit is contained in:
Aaron Power 2018-08-28 23:27:34 +01:00 committed by Andrew Gallant
parent 8f978a3cf7
commit d18839f3dc

View File

@ -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
}