Let's I have a function which takes in 5 one dimensional vectors. Performs operations like square roots , multiplication etc on them by accessing each element. Then returns a vector. This uses no functions .
There is another program which has combined three elements (one from each vector from the top) of three vectors in a struct. This struct overloads add operation and also has methods. Then this struct goes into another struct. We pass a vector of this struct to a function. Function body only consists of calling other methods. dyn keyword is not used here nothing is determined at runtime. Things once calculated are not calculated again but there is lot of passing of f64 to functions.
Will both programs be equally efficient in rust?
This has lot spaghetti code but as a example GitHub - Prashant-Shekhar-Rao/special_relativity_ray_caster: This program allows you to view relativistic effects, such as Terrell rotation, on 3D models through ray tracing. This works on OBJ files and doesn't have any requirements except having the executable.
Everything important happens in camera. I know passing three dimensional vector is inefficient but it only happens once so i am not changing it. On a side note I also know that practically speaking using multi threading and other rendering techniques would benefit far more in this specific case but i am asking this question more generally.
What are the things which are actually zero cost.
This did not solve the exact problem I asked the question for but it is a pretty great answer to the title question.