tl;dr
Is it possible to instantiate a generic Swift 4 enum member with an associated value of type Void
?
Background
I'm using a simple Result enum (similar to antitypical Result):
enum Result<T> {
case success(T)
case error(Error?)
}
Now I'd like to use this enum to represent the result of an operation which does not yield an actual result value; the operation is either succeeded or failed. For this I'd define the type as Result<Void>
, but I'm struggling with how to create the Result instance, neither let res: Result<Void> = .success
nor let res: Result<Void> = .success()
works.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…