Hacker News new | past | comments | ask | show | jobs | submit login

The one thing I don't like about Rust is the implicit return. Looking at code, it's easier to spot a missing/extra "return" than a missing/extra ";".



If you put an "extra" (unintended) semicolon on the last expression, the function will return Void/Unit: if this doesn't agree with the given type of the function, then there will be a compiler error. If you forget a semicolon, then the type of the function will become the type of the last expression, which will again make the compile complain.

Are there other issues that you had in mind?


The C++ will complain as well, the issue is ";" is 6 times less characters than "return" and so, easier to overlook.


I think I'd rather have that problem than this problem:

    if (cond); //oops, a semicolon
        alwaysHappens();
, thank you very much.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: