From caae932117da3be694625b06c062cee1b2e488fa Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 12 Jun 2023 05:05:57 -0700 Subject: [PATCH] Remove unnecessary lifetime markers --- native/src/base/files.rs | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/native/src/base/files.rs b/native/src/base/files.rs index cc8939c77..fbd535270 100644 --- a/native/src/base/files.rs +++ b/native/src/base/files.rs @@ -3,7 +3,6 @@ use std::cmp::min; use std::ffi::CStr; use std::fs::File; use std::io::{BufRead, Read, Seek, SeekFrom, Write}; -use std::marker::PhantomData; use std::ops::Deref; use std::os::fd::{AsFd, BorrowedFd, IntoRawFd}; use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd, RawFd}; @@ -185,7 +184,7 @@ impl WriteExt for T { } pub struct DirEntry<'a> { - dir: &'a Directory<'a>, + dir: &'a Directory, entry: &'a dirent, d_name_len: usize, } @@ -267,9 +266,8 @@ impl Deref for DirEntry<'_> { } } -pub struct Directory<'a> { +pub struct Directory { dirp: *mut libc::DIR, - _phantom: PhantomData<&'a libc::DIR>, } pub enum WalkResult { @@ -278,13 +276,10 @@ pub enum WalkResult { Skip, } -impl<'a> Directory<'a> { +impl Directory { pub fn open(path: &CStr) -> io::Result { let dirp = unsafe { libc::opendir(path.as_ptr()) }.check_os_err()?; - Ok(Directory { - dirp, - _phantom: PhantomData, - }) + Ok(Directory { dirp }) } pub fn read(&mut self) -> io::Result>> { @@ -345,7 +340,7 @@ impl<'a> Directory<'a> { } } -impl Directory<'_> { +impl Directory { fn post_order_walk_impl io::Result>( &mut self, f: &mut F, @@ -396,31 +391,28 @@ impl Directory<'_> { } } -impl TryFrom for Directory<'_> { +impl TryFrom for Directory { type Error = io::Error; fn try_from(fd: OwnedFd) -> io::Result { let dirp = unsafe { libc::fdopendir(fd.into_raw_fd()) }.check_os_err()?; - Ok(Directory { - dirp, - _phantom: PhantomData, - }) + Ok(Directory { dirp }) } } -impl AsRawFd for Directory<'_> { +impl AsRawFd for Directory { fn as_raw_fd(&self) -> RawFd { unsafe { libc::dirfd(self.dirp) } } } -impl<'a> AsFd for Directory<'a> { - fn as_fd(&self) -> BorrowedFd<'a> { +impl AsFd for Directory { + fn as_fd(&self) -> BorrowedFd { unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) } } } -impl Drop for Directory<'_> { +impl Drop for Directory { fn drop(&mut self) { unsafe { libc::closedir(self.dirp);