Oddbean new post about | logout
 @d05bf930 Check out this awesome video which talks about transformations between Result and Option:

https://www.youtube.com/watch?v=s5S2Ed5T-dc

`ok()` gives you the Ok variant as an Option. You loose information about the error.

You can't use `ok()` on an Option because you need to specify an error. You need to give it information. Therefore, you can use `ok_or`.

But if your error has to be computed (like a String which allocates), then you want that computation to be lazy with `ok_or_else` and only run on None.

https://cdn.fosstodon.org/media_attachments/files/111/130/690/663/922/659/original/7596e529390f2955.png