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.


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

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.