Skip to content

There is no way to create Box<str> #18283

Closed
@japaric

Description

@japaric

I'm working on #16918, and as part of the DSTification of Hash, I'm adding tests to make sure that hashing Box<[T]> and Box<str> work. But there doesn't seem to be a way to create a boxed str.

I tried the following:

fn main() {
    let _: Box<str> = box "a";
    //^~ error: mismatched types: expected `Box<str>`, found `Box<&'static str>`
    let _: Box<str> = box *"a";
    //^~ error: cannot move a value of type str: the size of str cannot be statically determined
}

cc @nick29581

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DSTsArea: Dynamically-sized types (DSTs)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions