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

Implement AsRef<Path> for Arc<PathBuf> #58469

Closed
vitiral opened this issue Feb 14, 2019 · 4 comments
Closed

Implement AsRef<Path> for Arc<PathBuf> #58469

vitiral opened this issue Feb 14, 2019 · 4 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@vitiral
Copy link
Contributor

vitiral commented Feb 14, 2019

Possibly also implement Borrow and Deref.

I would like to use Arc<PathBuf> to be the equivalent of PathBuf for traits in my library, path_abs.

However, I get errors like this:

751 | impl PathMut for Arc<PathBuf> {
    |      ^^^^^^^ the trait `std::convert::AsRef<std::path::Path>` is not implemented for `alloc::sync::Arc<std::path::PathBuf>`
    |
    = help: the following implementations were found:
              <alloc::sync::Arc<T> as std::convert::AsRef<T>>
    = note: required because of the requirements on the impl of `PathInfo` for `alloc::sync::Arc<std::path::PathBuf>`
@jonas-schievink jonas-schievink added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 14, 2019
@abonander
Copy link
Contributor

You can also get Arc<Path> via .into() on &Path or PathBuf.

@vitiral
Copy link
Contributor Author

vitiral commented Feb 15, 2019

Of course, but that doesn't let you generalize for trait bounds in a library.

@JanBeh
Copy link
Contributor

JanBeh commented Jul 20, 2022

To my understanding, adding new implementations of AsRef for smart pointers like Arc breaks type inference because of how some code currently uses .as_ref(). That said, I still think Arc<PathBuf> should implement AsRef<Path>. But it may be difficult to tackle.

Perhaps this issue could be closed and refer to #45742 for a (hopefully future) general solution of the problem.

@Enselic
Copy link
Member

Enselic commented Apr 7, 2024

Triage: There were no objections to close as duplicate, so let's do that.

Duplicate of #45742

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants