Skip to content

[DRAFT] Replace AsRef<Path> with PathLike #107534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Jan 31, 2023

A minimal implementation of rust-lang/libs-team#62.

pub trait PathLike {
    /// Convert to a `Path` reference.
    fn with_path<T, F: FnOnce(&Path) -> T>(&self, f: F) -> T;
    /// Convert to the native platform representation of a path.
    fn with_native_path<T, F: FnOnce(&NativePath) -> io::Result<T>>(&self, f: F) -> io::Result<T>;
}

/// Represents a path in the OS' native format.
///
/// Use OS specific extension trait to access the inner type.
pub struct NativePath(/* private */);

To keep things simple, this PR currently only uses with_native_path within File::open. Other fs function use with_path.

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 31, 2023
@ChrisDenton
Copy link
Member Author

@rustbot label -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 31, 2023
@ChrisDenton ChrisDenton changed the title Replace AsRef<Path> with PathLike [DRAFT] Replace AsRef<Path> with PathLike Feb 7, 2023
@ChrisDenton ChrisDenton added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 28, 2023
Replace `AsRef<Path>` with a `PathLike` trait.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants