Skip to content

Path::join(Self, &PathPart) -> Self #665

@Kinrany

Description

@Kinrany

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Path has method child for adding a single segment to the path. It clones the inner String but doesn't take ownership of the Path. This ends up cloning unnecessarily if the original Path will be dropped.

Describe the solution you'd like

impl Path {
    fn join(self, child: impl Into<PathPart<'_>>) -> Self;
}

Describe alternatives you've considered
Bikeshedding: what should be done with the existing Path::child?

One option is to change it directly instead of adding a new method. This would be a breaking change of course.

Another option is to deprecate child, replace its implementation with .clone().join(), and recommend that users inline it immediately.

Yet another option is to keep both methods. Less API churn, but larger API surface long-term.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions