|
That's a generic container of 0 or 1 elements ;) It's also incredibly unsafe and why generics aren't enough. C++, Java, and so on have had generics for ages and with types like the one above, null pointer exceptions are incredibly common. Nothing prevents the user from attempting to retrieve the data without first retrieving the success status. On the other hand, this improves on it dramatically: enum Result<T, E> {
Success(T),
Failure(E)
}
|