- This was a placeholder for me while I still formulate my ideas, I have edited for clarity.
I'm imagining a situation similar to javascript's ===
vs ==
, although the reasoning would be performance rather than correctness. Look at the following example:
fn src() -> Result<usize, usize> { /*...*/ }
fn foo() {
if src() ~= Ok(0) {
/* stuff */
}
}
fn bar() {
if src() == Ok(0) {
/* stuff */
}
}
If you view the MIR, foo has fewer memory accesses. I do not know MIR intimately, I do see that Bar creates 3 references and use
s a promoted
.