Lifetime-renaming action!

This commit is contained in:
Ben S 2015-05-12 15:38:12 +01:00
parent 07ff10e550
commit 00ae71850b
2 changed files with 12 additions and 12 deletions

View File

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

View File

@ -37,16 +37,16 @@ mod output;
mod term;
#[cfg(not(test))]
struct Exa<'a> {
struct Exa<'dir> {
count: usize,
options: Options,
dirs: Vec<PathBuf>,
files: Vec<File<'a>>,
files: Vec<File<'dir>>,
}
#[cfg(not(test))]
impl<'a> Exa<'a> {
fn new(options: Options) -> Exa<'a> {
impl<'dir> Exa<'dir> {
fn new(options: Options) -> Exa<'dir> {
Exa {
count: 0,
options: options,
@ -67,8 +67,8 @@ impl<'a> Exa<'a> {
let (thread_capacity_tx, thread_capacity_rs) = sync_channel(8 * num_cpus::get());
// Communication between consumer thread and producer threads
enum StatResult<'a> {
File(File<'a>),
enum StatResult<'dir> {
File(File<'dir>),
Path(PathBuf),
Error
}