rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.15k stars 12.69k forks source link

Tracking Issue for dir_entry_ext2 #85573

Open arennow opened 3 years ago

arennow commented 3 years ago

Feature gate: #![feature(dir_entry_ext2)]

This is a tracking issue for a new method on std::fs::DirEntry on UNIX platforms via a new sealed variant of the std::os::unix::fs::DirEntryExt trait.

Public API

#[unstable(feature = "dir_entry_ext2")]
pub trait DirEntryExt2: Sealed {
    fn file_name_ref(&self) -> &OsStr;
}

Steps / History

Unresolved Questions

marcospb19 commented 3 years ago

Hey, @arennow and @m-ou-se, is it possible to have an owned version of this function?

(self) -> OsString

Something like this in the trait

#[unstable(feature = "dir_entry_ext2")]
pub trait DirEntryExt2: Sealed {
    fn file_name_ref(&self) -> &OsStr;
    fn into_file_name(self) -> OsStr;
}
tavianator commented 2 years ago

@marcospb19 An owned version is already available from DirEntry::file_name()

mic006 commented 1 year ago

Hi @arennow and @m-ou-se

Is it planned to make this change stable in a coming release ? The change seems to be a good optimization (typically for sorting DirEntry-s), without any risk of issue.

cgwalters commented 4 months ago

Another year later: I also came across this one after writing some code to sort directory entries and thinking about the allocations involved.

It looks like we got hung up previously on the extension trait sealing: https://github.com/rust-lang/rust/pull/83581#issuecomment-808795847

I guess we need another crater run?