Super useful diagram that explains all available transformations between Result and Option standard #Rust types and their interactions.

Source: https://docs.google.com/drawings/d/1EOPs0YTONo_FygWbuJGPfikO9Myt5HwtiFUHRuE1JVM/edit

Rust Result/Option Transformations

Result<T, E> Result<U, E> Result<T, F> Option<T> T E Option<E> unwrap, expect, unwrap_or[_else], unwrap_or_default () unwrap_err, expect_err Err(e) Ok(t) Some(t) ok_or[_else] ok err map, and[_then] map_err None or[_else] Option<U> map, and[_then] U map_or [_else] filter, xor, or[_else], replace

Google Docs
@raptor very cool. need an async version of this that can do it across `.awaits`.

@raptor When I saw this I momentarily thought "These are REAL types, used by REAL Rustaceans... They have played us for absolute fools."

But on closer inspection actually super useful, thanks 😅

@projectgus @raptor yeah, I have defined them in C++ and use them all the time there too. Monads, functors and applicatives are pretty cool