Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your local style guide can’t override this?

Just turn people loose on your codebase without supervision and be really surprised that the hackers make off with your data?

You, sir, are arguing from bad faith as your obvious mission is to promote “rust in all the places”.



Our style guide says "almost never auto," but most people auto everything. They can make the linter replace auto with the actual type if it's really that big a deal. Explicit type wouldn't have avoided this bug.


Arguably an explicit type would have made the bug a little bit more obvious. You basically expect, by default, this kind of string manipulation functions to return a std::string. Obviously in this specific case you can return a view, and that makes it more performant; but it's kind of unexpected and using auto leaves the surprise a bit more hidden.

But sure, you can still make the error with expiclit types.


I agree, the string_view on the LHS might make you think more about the lifetime, but I'm pretty sure we all would've missed it.




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

Search: