Skip to content
Snippets Groups Projects
Commit 4efe9bc1 authored by Ruben Asplund's avatar Ruben Asplund
Browse files

Exercise A

parent 43ee88ae
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,11 @@ fn main() { ...@@ -37,7 +37,11 @@ fn main() {
// Try to explain in your own words the difference and why? // Try to explain in your own words the difference and why?
// (Hint, even if we don't use the result `b`, Rust do not optimize out the call, why?) // (Hint, even if we don't use the result `b`, Rust do not optimize out the call, why?)
// //
// [your answer here] // [There are 10 path with debug/dev mode and 2 path on release mode.
// In the debug mode/dev 8 of the paths is 8 for each loop, 1 path is for panic when index is out of range.
// The release mode is optimizing out all the loops, which means there are only two paths; one inside the loop
// and one outside. The b is not optimized out because the calculation of b can have side effects and
// code with side effects are not optimized out.]
// //
// B) Fix the code so that you don't get an error. // B) Fix the code so that you don't get an error.
// (It should still compute the sum of the n first elements // (It should still compute the sum of the n first elements
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment