mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-11 02:03:08 +00:00
Re-introduce placeholder
This commit is contained in:
parent
b4bed3ff52
commit
ab4d65ac83
@ -1,12 +1,15 @@
|
||||
import std/options
|
||||
import std/macros
|
||||
|
||||
proc placeholder(T: type): T =
|
||||
discard
|
||||
|
||||
template questionableUnpack*[T](expression: Option[T]): (T, bool) =
|
||||
## Used internally
|
||||
|
||||
let option = expression
|
||||
type T = typeof(option.unsafeGet())
|
||||
let res = if option.isSome: option.unsafeGet() else: default(T)
|
||||
let res = if option.isSome: option.unsafeGet() else: placeholder(T)
|
||||
(res, option.isSome)
|
||||
|
||||
macro `=?`*(name, expression): bool =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user