4 ms·
Rust doesn't allow assignment in conditionals. https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/content/porting_from_cpp/assignments_in_conditionals.ht
by capitainenemo 5y ago
Rust doesn't allow assignment in conditionals.
https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/content/porting_from_cpp/assignments_in_conditionals.html https://locka99.gitbooks.io/a-guide-to-porting-c-to-rust/con...
- _3u10 5y agoIt does, in fact the article you posted, shows you exactly when rust allows assignment in conditionals. As long as you're initializing a variable, it's allowed, if you're not initializing you'll have to use a block expression.
- capitainenemo 5y agoShould have just used this sentence - which also directly covers parent's case. "Rust does not allow assignment within simple expressions so they will fail to compile. This is done to prevent subtle errors with = being used instead of ==." Better?