mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-25 00:33:11 +00:00
Demonstrating a binding err
This commit is contained in:
parent
0c3d1dd563
commit
fa97db70dd
8
main.nim
Normal file
8
main.nim
Normal file
@ -0,0 +1,8 @@
|
||||
# Run this file:
|
||||
# nim c -r main.nim
|
||||
#
|
||||
|
||||
import ./somefn
|
||||
import ./otherfn
|
||||
|
||||
discard int.someFn()
|
||||
10
otherfn.nim
Normal file
10
otherfn.nim
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
|
||||
import ./somefn
|
||||
|
||||
proc otherFn*(): void =
|
||||
|
||||
without x =? int.someFn(), err:
|
||||
echo "was err" & err.msg
|
||||
14
somefn.nim
Normal file
14
somefn.nim
Normal file
@ -0,0 +1,14 @@
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
|
||||
proc someFn*(
|
||||
X: type int
|
||||
): ?!int =
|
||||
let res = success(1)
|
||||
|
||||
if err =? res.errorOption:
|
||||
echo "err" & err.msg
|
||||
else:
|
||||
echo "no err"
|
||||
|
||||
failure("")
|
||||
Loading…
x
Reference in New Issue
Block a user