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

Having unwrap() in your Rust code is like littering your code base with panic(). It’s not appropriate to use in most production code, but is convenient in prototypes, examples and tests.

Your example re Go errors is incorrect. The go compiler allows you to ignore errors in returns without any compiler error.

For example

err := doThingThatErrs()

and

doThingThatErrs()

are both valid Go code.



There's nothing wrong with unwrap. It's just an assert. Even a[i] is just shorthand for a.get(i).unwrap(). Asserts are definitely appropriate in production code, just not for handling run-time errors.


Then how is this better than anything else? Except for syntactical sugar for:

Try Return [Bla(), null] Catch err Return [null, err] End

I do like this syntax better, bc the different scopes cause a lot of nesting


My example is correct I explained all of that, multi values -> need to omit, single value can ignore everything.


Yup. I misspoke. We’re both right.




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

Search: