Oddbean new post about | logout
 @5150cec1 I think my complaint here is not that there are too many functions/methods, but more that it's hard to discover and remember which functions to use in which circumstances.  

An easy example: Result<T> has an .ok() method and Option<T> has an .ok_or() method.  I am constantly trying to call .ok() on an Option (or .ok_or() on Result) and then getting really confused when it tells me the function doesn't exist. 
 @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