fn main() {
let s = String::from("hello"); // s comes into scope
takes_ownership(s); // s's value moves into the function...
// ... and so is no longer valid here
} // Here, x goes out of scope, then s. But because s's value was moved, nothing
// special happens.
fn takes_ownership(some_string: String) { // some_string comes into scope
println!("{}", some_string);
} // Here, some_string goes out of scope and drop
is called. The backing
// memory is freed.
How is this implemented in binary code? Is stack is used to copy the argument of a method or function?
If so, didn't we have perfomance problem in comparance with C++ passing a pointer to a function?
I understand we can use unsafe rust for that. But this means for example everywhere we want to create data structure in a function or method we must copy it using stack too. So everythere we want ot use factory pattern we will use unsafe rust. This means well designed OOP code with good perfomance is always unsafe Rust code. Correct me if i'm wrong please.