Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
japaric opened this issue Oct 24, 2014 · 2 comments
Closed

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

japaric opened this issue Oct 24, 2014 · 2 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs)

Comments

@japaric
Copy link
Member

japaric commented Oct 24, 2014

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

@sfackler
Copy link
Member

Vec had this added: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.into_boxed_slice. We could do something similar for String.

@steveklabnik steveklabnik added the A-DSTs Area: Dynamically-sized types (DSTs) label Jan 27, 2015
@apasel422
Copy link
Contributor

This is now possible via String::into_boxed_str.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs)
Projects
None yet
Development

No branches or pull requests

4 participants