the.bay.news

Clarification on conditional assignment

Rust Internals
Clarification on conditional assignment
Hi everyone! I hope I don't come of as oblivious. I'm currently following the Interactive Rust Book and one of the quizzes presented in the topic of Control Flow in Rust is this: let x; if cond { x = 1; } else { x = 2; } Although it was explained briefly like this: Note that Rust does not require x to be initially declared with let mut in the second snippet. This is because Rust can determine that x is only ever assigned once, since only one branch of the if-statement will ever exe...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.