Add none[T]() as alias to none(T) (#7512)
* Add none[T]() as alias to none(T) * Add tests for none[T] * this test shouldn't work anyway
This commit is contained in:
parent
b2060acbc4
commit
38b2596ff9
1 changed files with 8 additions and 0 deletions
|
|
@ -104,6 +104,10 @@ proc none*(T: typedesc): Option[T] =
|
||||||
# the default is the none type
|
# the default is the none type
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
proc none*[T]: Option[T] =
|
||||||
|
## Alias for ``none(T)``.
|
||||||
|
none(T)
|
||||||
|
|
||||||
proc isSome*[T](self: Option[T]): bool {.inline.} =
|
proc isSome*[T](self: Option[T]): bool {.inline.} =
|
||||||
when T is SomePointer:
|
when T is SomePointer:
|
||||||
self.val != nil
|
self.val != nil
|
||||||
|
|
@ -290,3 +294,7 @@ when isMainModule:
|
||||||
|
|
||||||
let tmp = option(intref)
|
let tmp = option(intref)
|
||||||
check(sizeof(tmp) == sizeof(ptr int))
|
check(sizeof(tmp) == sizeof(ptr int))
|
||||||
|
|
||||||
|
test "none[T]":
|
||||||
|
check(none[int]().isNone)
|
||||||
|
check(none(int) == none[int]())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue