This commit is contained in:
2020-07-01 14:12:09 +02:00
commit f832858583
5 changed files with 70 additions and 0 deletions

17
src/oi.nim Normal file
View File

@@ -0,0 +1,17 @@
type
Err = string
OI*[T] = object of RootObj
case isOk*: bool
of true:
val*: T
of false:
error*: string
proc ok*[T](val: T): OI[T] =
OI[T](isOK: true, val: val)
proc fail*(oi: OI, msg: string): OI =
OI(isOK: false, error: msg)
proc fail*(msg: string): OI[auto] =
OI[auto](isOK: false, error: msg)