pub struct DirEntry { /* private fields */ }
Available on crate feature
root
only.Expand description
Entries returned by the ReadDir
iterator.
An instance of DirEntry
represents an entry inside of a directory on the
filesystem. Each entry can be inspected via methods to learn about the full
path or possibly other metadata through per-platform extension traits.
§Platform-specific behavior
On Unix, the DirEntry
struct contains an internal reference to the open
directory. Holding DirEntry
objects will consume a file handle even after
the ReadDir
iterator is dropped.
Implementations§
Source§impl DirEntry
impl DirEntry
Sourcepub fn file_name(&self) -> OsString
pub fn file_name(&self) -> OsString
Returns the file name of this directory entry without any leading path component(s).
As an example, the output of the function will result in “foo” for all the following paths:
- “./foo”
- “/the/foo”
- “../../foo”
§Examples
use relative_path_utils::Root;
let mut root = Root::new(".")?;
for entry in root.read_dir("src")? {
let entry = entry?;
println!("{:?}", entry.file_name());
}
Auto Trait Implementations§
impl Freeze for DirEntry
impl RefUnwindSafe for DirEntry
impl Send for DirEntry
impl Sync for DirEntry
impl Unpin for DirEntry
impl UnwindSafe for DirEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more