summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorhlaaf <hlaaftana@users.noreply.github.com>2018-04-16 22:01:37 +0300
committerAndreas Rumpf <rumpf_a@web.de>2018-04-16 21:01:37 +0200
commit38b2596ff9935e417df6165038c59840352e6a60 (patch)
tree630d2072dddf8e16601796bc1180bd918b4b3759 /lib/pure
parentb2060acbc49ccface03a2350bf1c2e9ad456a75d (diff)
downloadNim-38b2596ff9935e417df6165038c59840352e6a60.tar.gz
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
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/options.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim
index 8a771be71..aaffb57ca 100644
--- a/lib/pure/options.nim
+++ b/lib/pure/options.nim
@@ -104,6 +104,10 @@ proc none*(T: typedesc): Option[T] =
   # the default is the none type
   discard
 
+proc none*[T]: Option[T] =
+  ## Alias for ``none(T)``.
+  none(T)
+
 proc isSome*[T](self: Option[T]): bool {.inline.} =
   when T is SomePointer:
     self.val != nil
@@ -290,3 +294,7 @@ when isMainModule:
 
       let tmp = option(intref)
       check(sizeof(tmp) == sizeof(ptr int))
+
+    test "none[T]":
+      check(none[int]().isNone)
+      check(none(int) == none[int]())