Option type has a lot of convenience methods for quickly manipulating the value while leaving it in the
Option, providing defaults, and so on. Jason Orendorff and I were trying to get a grip on the naming conventions they follow, and produced this chart:
The chart is a little hard to get your head around, but once you get it, I think it’s pretty great. Find the method you want; the column and row headings tell you what it does.
One reason I like it is that it shows why I really hate the names of
map_or_else: they return the result of the closure call, not a
Some variant holding the result, The ordinary
map gets it right, following the precedent set by Haskell (and, I think, other languages?).
If you’d like to see the chart in its own page, it’s a Google doc.