According to the Rust link at the time of this writing:
For types that contain ownership pointers or values ββthat implement the special Drop attribute, the variable moves. All other types are copied.
Below is my code. I expect it to Pointbe a copy type. But it moves, and the following code will not compile with 0.13.0 at night.
struct Point {
x: uint,
y: uint
}
fn main() {
let p: Point = Point{x: 10u, y: 10u};
let p1 = p;
let p2 = p;
}
Compilation Error:
note: `p` moved here because it has type `Point`, which is moved by default
Why is it Pointnot considered as a type for copying?
source
share