mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-04-08 08:21:50 +00:00
Remove unused lifetime
This commit is contained in:
parent
05dd644c92
commit
8b3602f20f
@ -7,20 +7,20 @@ use file::File;
|
||||
// surrounding files, such as whether it needs to be coloured
|
||||
// differently if a certain other file exists.
|
||||
|
||||
pub struct Dir<'a> {
|
||||
pub struct Dir {
|
||||
pub contents: Vec<Path>,
|
||||
pub path: Path,
|
||||
}
|
||||
|
||||
impl<'a> Dir<'a> {
|
||||
pub fn readdir(path: Path) -> IoResult<Dir<'a>> {
|
||||
impl Dir {
|
||||
pub fn readdir(path: Path) -> IoResult<Dir> {
|
||||
fs::readdir(&path).map(|paths| Dir {
|
||||
contents: paths,
|
||||
path: path.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn files(&'a self) -> Vec<File<'a>> {
|
||||
pub fn files(&self) -> Vec<File> {
|
||||
let mut files = vec![];
|
||||
|
||||
for path in self.contents.iter() {
|
||||
|
@ -22,7 +22,7 @@ pub static GREY: Colour = Fixed(244);
|
||||
|
||||
pub struct File<'a> {
|
||||
pub name: String,
|
||||
pub dir: Option<&'a Dir<'a>>,
|
||||
pub dir: Option<&'a Dir>,
|
||||
pub ext: Option<String>,
|
||||
pub path: Path,
|
||||
pub stat: io::FileStat,
|
||||
@ -30,14 +30,14 @@ pub struct File<'a> {
|
||||
}
|
||||
|
||||
impl<'a> File<'a> {
|
||||
pub fn from_path(path: Path, parent: Option<&'a Dir<'a>>) -> IoResult<File<'a>> {
|
||||
pub fn from_path(path: Path, parent: Option<&'a Dir>) -> IoResult<File<'a>> {
|
||||
// Use lstat here instead of file.stat(), as it doesn't follow
|
||||
// symbolic links. Otherwise, the stat() call will fail if it
|
||||
// encounters a link that's target is non-existent.
|
||||
fs::lstat(&path).map(|stat| File::with_stat(stat, path.clone(), parent))
|
||||
}
|
||||
|
||||
pub fn with_stat(stat: io::FileStat, path: Path, parent: Option<&'a Dir<'a>>) -> File<'a> {
|
||||
pub fn with_stat(stat: io::FileStat, path: Path, parent: Option<&'a Dir>) -> File<'a> {
|
||||
let v = path.filename().unwrap(); // fails if / or . or ..
|
||||
let filename = String::from_utf8(v.to_vec()).unwrap_or_else(|_| panic!("Name was not valid UTF-8"));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user