Skip to content

OsStr: compare prefix #40300

Closed
Closed
@nagisa

Description

@nagisa

OsStr could implement a way to compare against prefix &str (as it does not implement iterators over its data), similarly to how it implements comparison against &str.

Currently you need to go out of your way to convert to bytes. as_str is not suitable, as following case shows:

let x = /* OsStr with invalid utf8 */;
x.as_str().map(|x| x.starts_with("-")).unwrap_or(false); // false even if only the first byte really matters

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.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