by fasterthanlime · 6y ago · 0 comments
It has its limits though - in your example I'd say you're throwing away the result of evaluating "x", just as if you did:
x;1:
let x = String::new();
let _ = x;
println!("{}", x);
2: let x = String::new();
x;
println!("{}", x); // ERROR: Use of moved value x.
And this is why I said that let _ = x; is a no-op. :) let _ = timeConsumingFunction();
Still needs to spend time performing timeConsumingFunction(). It might not move, but it still did the work and produced a result, you are just not using it (and hence not need to move it).If you you had lazy evaluation I would agree with your argument for the no-op terminology.