diff options
author | Ben S <ogham@bsago.me> | 2015-05-12 15:38:12 +0100 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-05-12 15:38:12 +0100 |
commit | 00ae71850bc927833f55e602c35a8dcffbc4dfc6 (patch) | |
tree | eca411e632aa253c7ad642aa6d83b1ea5bbe48d4 /src/file.rs | |
parent | 07ff10e550a589871399801b1245b4a45c7b08ee (diff) |
Lifetime-renaming action!
Diffstat (limited to 'src/file.rs')
-rw-r--r-- | src/file.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/file.rs b/src/file.rs index cd1589e..42f056f 100644 --- a/src/file.rs +++ b/src/file.rs @@ -21,9 +21,9 @@ use self::fields as f; /// once, have its file extension extracted at least once, and have its stat /// information queried at least once, so it makes sense to do all this at the /// start and hold on to all the information. -pub struct File<'a> { +pub struct File<'dir> { pub name: String, - pub dir: Option<&'a Dir>, + pub dir: Option<&'dir Dir>, pub ext: Option<String>, pub path: PathBuf, pub stat: fs::Metadata, @@ -31,18 +31,18 @@ pub struct File<'a> { pub this: Option<Dir>, } -impl<'a> File<'a> { +impl<'dir> File<'dir> { /// Create a new File object from the given Path, inside the given Dir, if /// appropriate. Paths specified directly on the command-line have no Dirs. /// /// This uses `symlink_metadata` instead of `metadata`, which doesn't /// follow symbolic links. - pub fn from_path(path: &Path, parent: Option<&'a Dir>, recurse: bool) -> io::Result<File<'a>> { + pub fn from_path(path: &Path, parent: Option<&'dir Dir>, recurse: bool) -> io::Result<File<'dir>> { fs::symlink_metadata(path).map(|stat| File::with_stat(stat, path, parent, recurse)) } /// Create a new File object from the given Stat result, and other data. - pub fn with_stat(stat: fs::Metadata, path: &Path, parent: Option<&'a Dir>, recurse: bool) -> File<'a> { + pub fn with_stat(stat: fs::Metadata, path: &Path, parent: Option<&'dir Dir>, recurse: bool) -> File<'dir> { let filename = path_filename(path); // If we are recursing, then the `this` field contains a Dir object @@ -340,7 +340,7 @@ fn path_filename(path: &Path) -> String { /// ASCII lowercasing is used because these extensions are only compared /// against a pre-compiled list of extensions which are known to only exist /// within ASCII, so it's alright. -fn ext<'a>(name: &'a str) -> Option<String> { +fn ext(name: &str) -> Option<String> { name.rfind('.').map(|p| name[p+1..].to_ascii_lowercase()) } |