Rename to op

This commit is contained in:
2020-07-01 22:37:19 +02:00
parent 7884ca4a8f
commit 1783232b8e
4 changed files with 22 additions and 24 deletions

View File

@@ -1,17 +0,0 @@
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*[T](msg: string): OI[T] =
OI[T](isOK: false, error: msg)

17
src/op.nim Normal file
View File

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