Trait std::os::unix::fs::DirEntryExt2[][src]

pub trait DirEntryExt2: Sealed {
    fn file_name_ref(&self) -> &OsStr;
}
🔬 This is a nightly-only experimental API. (dir_entry_ext2 #85573)
This is supported on Unix only.
Expand description

fs::DirEntry 的密封 Unix 特定扩展方法。

Required methods

🔬 This is a nightly-only experimental API. (dir_entry_ext2 #85573)

返回指向此条目文件名的基础 OsStr 的引用。

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

Implementors

🔬 This is a nightly-only experimental API. (dir_entry_ext2 #85573)