title: How does Rust deal with structs as function parameters and return values?
body: <p>I have some experience in C, but I'm new to Rust. What happens under the hood when I pass a struct into a function and I return a struct from a function? It seems it doesn't "copy" the struct, but if it isn't copied, where is the struct created? Is it in the stack of the outer function?</p>
  
  <pre><code>struct Point {
      x: i32,
      y: i32,
  }
  
  // I know it's better to pass in a reference here, 
  // but I just want to clarify the point.
  fn copy_struct(p: Point) { 
      // Is this return value created in the outer stack 
      // so it won't be cleaned up while exiting this function?  
      Point {.. p} 
  }
  
  fn test() {
      let p1 = Point { x: 1, y: 2 };
      // Will p1 be copied or does copy_struct 
      // just use a reference of the one created on the outer stack?
      let p2 = copy_struct(p1); 
  }
  </code></pre>