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

Cannot do x as Box<[T]> for x: Box<[T; k]> #22403

Closed
pnkfelix opened this issue Feb 16, 2015 · 1 comment
Closed

Cannot do x as Box<[T]> for x: Box<[T; k]> #22403

pnkfelix opened this issue Feb 16, 2015 · 1 comment
Labels
A-typesystem Area: The type system

Comments

@pnkfelix
Copy link
Member

This explicit cast does not work:

fn main() {
    let x = Box::new([1, 2, 3]);
    let y = x as Box<[i32]>;

    println!("y: {:?}", y);
}

However, this implicit coercion does work:

fn main() {
    let x = Box::new([1, 2, 3]);
    let y: Box<[i32]> = x;

    println!("y: {:?}", y);
}

It is unfortunate, because I would like the overloaded-box inference to work for expr as Box<[T]> in the same manner that it does for expr as Box<Trait>.

@pnkfelix
Copy link
Member Author

cc #22181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

2 participants