You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structGoodbye;implGoodbye{fnnew() -> Self{Goodbye}fnget(&self) -> bool{true}}implDropforGoodbye{fndrop(&mutself){println!("Dropping");}}fnmain(){let x = matchGoodbye::new().get(){true => {println!("In match");1},false => 0};println!("------");let y = ifGoodbye::new().get(){println!("In if");1}else{0};}
When compile this with rustc 1.19 and I execute this, the output is:
In match
Dropping
------
Dropping
In if
Thanks to the people who commented on issue #37612, I now understand why, in the match expression, the temporary is only dropped after printing "In match", but I expected the same behaviour in the if-expression, in other words, I expected the output to be:
I wrote the following code:
When compile this with rustc 1.19 and I execute this, the output is:
Thanks to the people who commented on issue #37612, I now understand why, in the
match
expression, the temporary is only dropped after printing "In match", but I expected the same behaviour in theif
-expression, in other words, I expected the output to be:Am I missing something, or is this a bug?
Info about my version of the compiler:
Out of curiosity, I have also tried with rustc 1.1.0 and then I got the output I expected.
The text was updated successfully, but these errors were encountered: