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

Yes that was a mistake.

unwrap() is the error.

unwrap_or() is the fallback.



Also unwrap_or_default() which is useful in many cases. For example the default for a string is empty string, default for integers is 0 and default for bool is false.

For your own types you can implement the Default trait to tell Rust what the default value is for that type.




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

Search: