Skip to content

Commit

Permalink
extend optValue support for Result[void, E] (#44)
Browse files Browse the repository at this point in the history
Fixes an error that shows when using `optValue` on a `Result[void, E]`.

```
undeclared field: 'vResultPrivate' for type results.Result
```
  • Loading branch information
etan-status authored Mar 11, 2024
1 parent 6340b04 commit d285bf0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion results.nim
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,10 @@ func optValue*[T, E](self: Result[T, E]): Opt[T] =
## Return the value of a Result as an Opt, or none if Result is an error
case self.oResultPrivate
of true:
Opt.some(self.vResultPrivate)
when T is void:
Opt[void].ok()
else:
Opt.some(self.vResultPrivate)
of false:
Opt.none(T)

Expand Down

0 comments on commit d285bf0

Please sign in to comment.