mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-09 11:45:42 +00:00
Some fixes for Result[T, void]
This commit is contained in:
parent
3e4dc8213b
commit
2b9e5f34d1
@ -498,12 +498,18 @@ func expect*[T: not void, E](self: Result[T, E], m: string): T =
|
||||
## echo r.expect("r was just set to ok(42)")
|
||||
## ```
|
||||
if not self.o:
|
||||
when E isnot void:
|
||||
raiseResultDefect(m, self.e)
|
||||
else:
|
||||
raiseResultDefect(m)
|
||||
self.v
|
||||
|
||||
func expect*[T: not void, E](self: var Result[T, E], m: string): var T =
|
||||
if not self.o:
|
||||
when E isnot void:
|
||||
raiseResultDefect(m, self.e)
|
||||
else:
|
||||
raiseResultDefect(m)
|
||||
self.v
|
||||
|
||||
func `$`*(self: Result): string =
|
||||
|
Loading…
x
Reference in New Issue
Block a user