3 ms·
(You don't use return there, but otherwise, you're correct about the Rust, yes. return would return from the function, not assign the value to x.)
by steveklabnik 5y ago
(You don't use return there, but otherwise, you're correct about the Rust, yes. return would return from the function, not assign the value to x.)
- themulticaster 5y agoWell, this is embarrassing. I'm using a small Rust example to make a point about C oddities, and then a Rust Core team member points out a syntax error in my example! In my defense, I'd say the return keyword - combined with the different semicolon rules - is one of the more confusing and subtle syntactic differences when learning Rust from a C/C++ background. After a few weeks of programming C++ I always use return more often than necessary.
- steveklabnik 5y agoOh absolutely! If you haven’t worked with expression-based languages before, it’s a big mental shift. In my experience it’s harder to come back to one that isn’t after you’ve done things this way for a while. There’s an adjustment period for sure.