Skip to content

Add to_path_buf() method for RelPath#16697

Merged
bors merged 1 commit intorust-lang:masterfrom
regexident:relpath-to-relpathbuf
Feb 27, 2024
Merged

Add to_path_buf() method for RelPath#16697
bors merged 1 commit intorust-lang:masterfrom
regexident:relpath-to-relpathbuf

Conversation

@regexident
Copy link
Copy Markdown
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
Copy Markdown
Member

Veykril commented Feb 27, 2024

@bors r+

@bors
Copy link
Copy Markdown
Contributor

bors commented Feb 27, 2024

📌 Commit 0005794 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Copy Markdown
Contributor

bors commented Feb 27, 2024

⌛ Testing commit 0005794 with merge 0ac05c0...

@bors
Copy link
Copy Markdown
Contributor

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
@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