What design pattern is Option<T> an example of?

I've begun to study object design patterns (especially the GoF ones), and I can't put a finger on what exactly Optional<T> is. The closest ones I can think of are Adapter, State or even Mediator, in a sense. What would you classify it as?

Rust isn't object-oriented so most GoF patterns tend not to match properly.
Optional<T> has nothing to do with any GoF patterns. You can consider it as a nullable type which you're forced to check whether its null or not.
It is also a Monad if you're really looking for patterns.

4 Likes

Sorry, I accidentally implied I wanted to fit Optional into a GoF pattern. Monad is certainly the best fit, thank you.