Closed
Description
struct Vector3<S>(S, S, S);
// passes type checking
fn into_vec3_arg<S>([x, y, z]: [S, ..3]) -> Vector3<S> {
Vector3(x, y, z)
}
fn into_vec3_let<S>(v: [S, ..3]) -> Vector3<S> {
let [x, y, z] = v; // error: use of moved value: `v[..]`
Vector3(x, y, z)
}
fn into_vec3_match<S>(v: [S, ..3]) -> Vector3<S> {
match v {
// error: use of moved value: `v[..]`
[x, y, z] => Vector3(x, y, z),
}
}
Note that it is impossible to work around this using transmute, because:
struct Vector3<S>(S, S, S);
fn into_vec3_transmute<S>(v: [S, ..3]) -> Vector3<S> {
// error: cannot transmute from a type that contains type parameters
unsafe { mem::transmute(v) }
}