Skip to content

The signature of Path::strip_prefix is bizarrely overconstrained #48390

Closed
@ExpHP

Description

@ExpHP
pub fn strip_prefix<'a, P: ?Sized>(
    &'a self, 
    base: &'a P  // <===  ???  a reference?
) -> Result<&'a Path, StripPrefixError> 
where P: AsRef<Path>, 

This can clearly be generalized to

pub fn strip_prefix<'a, P>(
    &'a self, 
    base: P
) -> Result<&'a Path, StripPrefixError> 
where P: AsRef<Path>, 

Implementation.

(Note: Like many similar attempts to "generalize" function signatures, this is a potentially breaking change due to potential regressions in type inference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions