From 38b2596ff9935e417df6165038c59840352e6a60 Mon Sep 17 00:00:00 2001 From: hlaaf Date: Mon, 16 Apr 2018 22:01:37 +0300 Subject: [PATCH] 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 --- lib/pure/options.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pure/options.nim b/lib/pure/options.nim index 8a771be719..aaffb57caa 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]())