Skip to content

Tracking Issue for PathBuf::add_extension and Path::with_added_extension #127292

Closed

Description

@tisonkun

Feature gate: #![feature(path_add_extension)]

This is a tracking issue for

  • PathBuf::add_extension
  • Path::with_added_extension

Public API

impl PathBuf {
    pub fn add_extension<S: AsRef<OsStr>>(&mut self, extension: S) -> bool { ... )
}

impl Path {
    pub fn with_added_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf { ... }
}

Steps / History

Implementation history

Unresolved Questions

None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jul 3, 2024
  2. changed the title [-]Tracking Issue for PathBuf::add_extension and Path::with_added_extension[/-] [+]Tracking Issue for PathBuf::add_extension and Path::with_extra_extension[/+] on Jul 3, 2024
  3. changed the title [-]Tracking Issue for PathBuf::add_extension and Path::with_extra_extension[/-] [+]Tracking Issue for PathBuf::add_extension and Path:: with_added_extension[/+] on Jul 4, 2024
  4. changed the title [-]Tracking Issue for PathBuf::add_extension and Path:: with_added_extension[/-] [+]Tracking Issue for PathBuf::add_extension and Path::with_added_extension[/+] on Jul 4, 2024
  5. MordechaiHadad commented on Aug 8, 2024

    @MordechaiHadad

    This would be really awesome honestly, just encountered an issue where this would have made my life easier.

  6. dilawar commented on Sep 22, 2024

    @dilawar

    Hoping this becomes available in stable soon. Such a nice QoL api.

  7. anatawa12 commented on Oct 16, 2024

    @anatawa12
    Contributor

    This new API is awesome!

    But I think It would be better to rename (deprecate old and add new name) existing API with_extension with with_replaced_extension and set_extension with replace_extension along with this feature.
    I feel existing function with_extension and set_extension is confusing if it will replace or append extension.

    Actually I mistakenly used with_extension as with_added_extension and we can see some such case in rust form like this.

  8. yara-blue commented on Dec 22, 2024

    @yara-blue
    Contributor

    But I think It would be better to rename (deprecate old and add new name) existing API with_extension with with_replaced_extension and set_extension with replace_extension along with this feature.

    I agree with the rename however we can only do that with a new edition (since with_extension is stable) right? And that might take a few more years. That should not block the stabilization of the added API.

  9. anatawa12 commented on Dec 23, 2024

    @anatawa12
    Contributor

    I don't think edition change is required since we don't have to actually rename the function.
    We can introduce with_replaced_extension in some version, and deprecate with_extension in following or later version.

    I think there are some cases that deprecating without edition change like deprecate _ms functions with Duration parameter variants.

  10. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    and removed
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jan 7, 2025
  11. joshtriplett commented on Jan 7, 2025

    @joshtriplett
    Member

    Starting an FCP to stabilize this:

    @rfcbot merge

  12. rfcbot commented on Jan 7, 2025

    @rfcbot

    Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

    No concerns currently listed.

    Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

    See this document for info about what commands tagged team members can give me.

  13. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Jan 7, 2025
  14. 27 remaining items

  15. added a commit that references this issue on Apr 24, 2025
  16. hanna-kruppe commented on Aug 10, 2025

    @hanna-kruppe
    Contributor

    Stabilization PR: #145209

  17. Timmmm commented on Aug 10, 2025

    @Timmmm
    Contributor

    IMO it's still a mistake to stabilize the panicking version of with_added_extension(). I don't think anyone has disagreed that:

    1. with_extension() is a confusing name that should be changed to with_replaced_extension().
    2. It's preferable to return Result<> instead of panicking.

    If we were to deprecate with_extension() and add with_replaced_extension() -> Result<> then we could also have with_added_extension() -> Result<> and it wouldn't be inconsistent. (It wasn't explicitly stated but I assume inconsistency with with_extension() was reason to copy its mistake to with_added_extension().)

    If we stabilise this PR I think we're probably stuck with this sub-par API forever.

    I suggest:

    1. Add with_replaced_extension() -> Result<>
    2. Change with_added_extension() to return Result<>
    3. Deprecate with_extension(), because it's confusingly named and has surprising panics.

    I'd be happy to implement this if it would be accepted.

  18. hanna-kruppe commented on Aug 10, 2025

    @hanna-kruppe
    Contributor

    I don't think anyone has disagreed that:

    People (including libs-api members) very much have disagreed, several times, in the above discussion and in meetings reported in comments on this issue. Just not in response to your comment specifically because very similar points were raised by others before. That doesn’t mean the team can’t change its mind now, but it’s not new information either.

  19. added a commit that references this issue on Sep 3, 2025
  20. added a commit that references this issue on Sep 3, 2025
  21. added 3 commits that reference this issue on Sep 3, 2025
  22. added a commit that references this issue on Sep 4, 2025
  23. added this to the 1.91.0 milestone on Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions