I have some experience working in C, but I'm new to Rust. What happens under the hood when I pass the structure to the function and return the structure from the function? This does not seem to “copy” the structure, but if it is not copied, then where is the structure created? Is it a stack of external function?
struct Point {
x: i32,
y: i32,
}
fn copy_struct(p: Point) {
Point {.. p}
}
fn test() {
let p1 = Point { x: 1, y: 2 };
let p2 = copy_struct(p1);
}
source
share