Skip to content

unsafe String constructors as free functions are inconsistent with design elsewhere #16708

@thestinger

Description

@thestinger

In the past we agreed to get rid of these unsafe functions and replace them with static methods, but they've come back on strings and the previous methods are marked as deprecated. AFAIK, this did not go through an RFC, and is inconsistent with the design used elsewhere in the standard library based on the strong consensus in the previous discussions on the mailing list and issue tracker. For example, from_raw_parts is a method on Vec and was a method on String but has been deprecated.

Static methods play very well with Rust's import system, because it allows accessing all of the methods via the scope. It's already marked unsafe, and going out of the way to make unsafe code painful just makes the language lose appeal as a systems language.

The parameters also shifted around in from_parts relative to from_raw_parts on Vec and String, so even that part of the design is inconsistent with Vec<T>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions