I’m trying to understand the move semantics of rust, and have a problem about the handling of the return value of a function.
The question is that:
If I have such a struct:
and such a function that returns above struct:
Then the caller calls the function as
Would the x own the object EXACTLY (have same memory address) the same that I created in the function someFunc?
If not, the struct must be copied, then in language like C++, the behavior of coping of struct can be user-defined in copy constructor, How does rust handle the copy?
If yes, does it mean that rust guarantee return value optimization?
Actually there was such a topic on this issue:
But I failed to find a firm result.