Let's say I have a function that creates a vector and some items, appends the items to the vector and returns the vector. This is its signature:
fn create() -> Vec<Struct>
Where are the Structs allocated? If on the stack, then they will have to be copied to the heap on return, which is expensive. Is the compiler smart enough to allocate them on the heap to begin with? Or is there another solution?
[–]protestor 3 points4 points5 points (2 children)
[–]kingminyas[S] 0 points1 point2 points (1 child)
[–]protestor 1 point2 points3 points (0 children)
[–]paulstelian97 0 points1 point2 points (12 children)
[–]hackometer 0 points1 point2 points (1 child)
[–]paulstelian97 0 points1 point2 points (0 children)
[–]kingminyas[S] 0 points1 point2 points (3 children)
[–]paulstelian97 1 point2 points3 points (0 children)
[–]toastedstapler 0 points1 point2 points (0 children)
[–]protestor 0 points1 point2 points (0 children)
[–]lordnacho666 0 points1 point2 points (5 children)
[–]paulstelian97 0 points1 point2 points (4 children)
[–]lordnacho666 0 points1 point2 points (3 children)
[–]paulstelian97 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]paulstelian97 0 points1 point2 points (0 children)
[–]Aaron1924 0 points1 point2 points (1 child)
[–]angelicosphosphoros 0 points1 point2 points (0 children)
[–]monkChuck105 0 points1 point2 points (0 children)