Skip to content
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

Add to_path_buf() method for RelPath #16697

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

regexident
Copy link
Contributor

There seems to be no ergonomic way to obtain a RelPathBuf from a corresponding &RelPath at the moment, making the latter sort of a dead end.

The AbsPath type provides the following:

impl AbsPath {
    // ...

    /// Equivalent of [`Path::to_path_buf`] for `AbsPath`.
    pub fn to_path_buf(&self) -> AbsPathBuf {
        AbsPathBuf::try_from(self.0.to_path_buf()).unwrap()
    }

    // ...
}

So I took the liberty of adding a corresponding equivalent for `RelPath:

impl RelPath {
    // ...

    /// Equivalent of [`Path::to_path_buf`] for `RelPath`.
    pub fn to_path_buf(&self) -> RelPathBuf {
        RelPathBuf::try_from(self.0.to_path_buf()).unwrap()
    }

    // ...
}

(the change is motivated by an outside use of the ra_ap_paths crate that would benefit from being able to use RelPath and AbsPath over Path)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2024
@Veykril
Copy link
Member

Veykril commented Feb 27, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 27, 2024

📌 Commit 0005794 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Feb 27, 2024

⌛ Testing commit 0005794 with merge 0ac05c0...

@bors
Copy link
Collaborator

bors commented Feb 27, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 0ac05c0 to master...

@bors bors merged commit 0ac05c0 into rust-lang:master Feb 27, 2024
11 checks passed
@regexident regexident deleted the relpath-to-relpathbuf branch February 27, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants