-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Cannot do x as Box<[T]> for x: Box<[T; k]> #22403
Copy link
Copy link
Closed
Labels
A-type-systemArea: Type systemArea: Type system
Description
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>.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type system
Type
Fields
Give feedbackNo fields configured for issues without a type.