parent
b4b3841a85
commit
6d3e6a21ca
|
@ -442,7 +442,7 @@ template capture*[E: Exception](T: type, someExceptionExpr: ref E): Result[T, re
|
|||
ret = R.err(caught)
|
||||
ret
|
||||
|
||||
func `==`*[T0, E0, T1, E1](lhs: Result[T0, E0], rhs: Result[T1, E1]): bool {.inline.} =
|
||||
func `==`*[T0: not void, E0, T1: not void, E1](lhs: Result[T0, E0], rhs: Result[T1, E1]): bool {.inline.} =
|
||||
if lhs.o != rhs.o:
|
||||
false
|
||||
elif lhs.o: # and rhs.o implied
|
||||
|
@ -450,6 +450,12 @@ func `==`*[T0, E0, T1, E1](lhs: Result[T0, E0], rhs: Result[T1, E1]): bool {.inl
|
|||
else:
|
||||
lhs.e == rhs.e
|
||||
|
||||
func `==`*[E0, E1](lhs: Result[void, E0], rhs: Result[void, E1]): bool {.inline.} =
|
||||
if lhs.o != rhs.o:
|
||||
false
|
||||
else:
|
||||
lhs.e == rhs.e
|
||||
|
||||
func get*[T: not void, E](self: Result[T, E]): T {.inline.} =
|
||||
## Fetch value of result if set, or raise Defect
|
||||
## Exception bridge mode: raise given Exception instead
|
||||
|
|
|
@ -275,3 +275,8 @@ func cstringF(s: string): CSRes =
|
|||
doAssert false
|
||||
|
||||
discard cstringF("test")
|
||||
|
||||
# Compare void
|
||||
block:
|
||||
var a, b: Result[void, bool]
|
||||
discard a == b
|
||||
|
|
Loading…
Reference in New Issue