Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tyingq
on March 7, 2017
|
parent
|
context
|
favorite
| on:
Zcoin implementation bug enabled attacker to creat...
Interesting. Is there any plausible way that Rust can fall into the == vs = trap?
steveklabnik
on March 7, 2017
|
next
[–]
No, as assignment always results in (), and if always requires a boolean. This is by design.
tyingq
on March 7, 2017
|
parent
|
next
[–]
Ah...so this works:
fn main() { let mut x = false; println!("{}", x); if {x=true;x} { println!("{}", x); } }
But stands out as pretty obvious. Not something you might easily sneak into a codebase.
steveklabnik
on March 7, 2017
|
root
|
parent
|
next
[–]
Sneaky! Yeah, no way this should get past code review, and not even easy to accidentally type.
aethertap
on March 7, 2017
|
prev
[–]
I haven't yet reached the level of Rust mastery where I'm confident in this answer, but as far as I can tell it's very hard to make that kind of mistake. I'd be very interested to hear what others have to say on it though.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: