Now, I already know that statically-sized arrays of primitives are
implicitly copyable, but consider, for example, a statically-sized array of
a non-copyable but Clone-able type. I find that for v of type [T, ..2],
v.clone() is not a static array. Perhaps it's because v is being
implicitly treated as &[T] instead.
Eg.
--------------------------------------------------
fn make_clone<T : Clone>(a : &T) -> T {
a.clone();
}
fn main() {
let a : [int, ..2] = [1, 2];
// error: failed to find an implementation of trait std::clone::Clone
// for [int, .. 2]
make_clone(&a);
let a : [int, ..2] = [1, 2];
// error: mismatched types: expected `[int, .. 2]` but found `&[int]`
// ([] storage differs: expected 2 but found &)
let b : [int, ..2] = a.clone();
}
--------------------------------------------------
So is it a missing feature of rust that Clone is not supported generated
for statically-sized arrays or is there a more fundamental reason that it
doesn't exist?
Ashish
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev