Skip to content

Documentation of the From<String> impl for OsString misleading #72349

Closed
@smarnach

Description

@smarnach

The documentation of From<String> for OsString reads

Converts a String into a OsString.

The conversion copies the data, and includes an allocation on the heap.

The implementation is platform-specific, but from a quick glance none of the implementations I looked at does seem to actually copy the data.

The documentation of From<String> for PatBbuf reads

Converts a String into a PathBuf

This conversion does not allocate or copy memory.

It is implemented using OsString::from::<String>:

fn from(s: String) -> PathBuf {
    PathBuf::from(OsString::from(s))
}

So clearly something is off here. Even when all current implementations of the String to OsString conversion avoid copying, the documentation does not necessarily need to commit to this property, but neither should it state that the implementation allocates and copies if it actually doesn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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