Trait std::os::unix::fs::DirEntryExt2
pub trait DirEntryExt2: Sealed { fn file_name_ref(&self) -> &OsStr; }
This is supported on Unix only.
Sealed Unix-specific extension methods for fs::DirEntry
.
Required methods
fn file_name_ref(&self) -> &OsStr
Returns a reference to the underlying OsStr
of this entry’s filename.
Examples
#![feature(dir_entry_ext2)] use std::os::unix::fs::DirEntryExt2; use std::{fs, io}; fn main() -> io::Result<()> { let mut entries = fs::read_dir(".")?.collect::<Result<Vec<_>, io::Error>>()?; entries.sort_unstable_by(|a, b| a.file_name_ref().cmp(b.file_name_ref())); for p in entries { println!("{:?}", p); } Ok(()) }
Implementors
impl DirEntryExt2 for DirEntry
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/fs/trait.DirEntryExt2.html