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
The "Speaker Notes" in Destructuring Enums mentioned that:
Save the result of divide_in_two in the result variable and match it in a loop. That won’t compile because msg is consumed when matched. To fix it, match &result instead of result. That will make msg a reference so it won’t be consumed.
However, I tried this and it compiles successfully even without the &. Is it because new rustc version somehow fixed this issue?
The text was updated successfully, but these errors were encountered:
fn main() {
let n = 100;
let result = divide_in_two(n);
loop {
match result {
Result::Ok(half) => println!("{n} divided in two is {half}"),
Result::Err(msg) => println!("sorry, an error happened: {msg}"),
}
}
}
BTW, please try to use text to represent text, rather than images -- in this case I couldn't copy/paste from your example because it's an image.
The "Speaker Notes" in Destructuring Enums mentioned that:
However, I tried this and it compiles successfully even without the
&
. Is it because newrustc
version somehow fixed this issue?The text was updated successfully, but these errors were encountered: