diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-06-06 02:54:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-05 20:54:25 +0200 |
commit | 87e56cabbb4d0d7326c37799d34d10e395a970fc (patch) | |
tree | 97a11ad249b57ae6cd76096e2b55a4916f92f2d8 /lib/pure | |
parent | 2d1533f34f74d69978f20d09be28740be2ec721c (diff) | |
download | Nim-87e56cabbb4d0d7326c37799d34d10e395a970fc.tar.gz |
make `std/options` compatible with strictdefs (#23675)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/options.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim index b7a6a6212..b34ff72c0 100644 --- a/lib/pure/options.nim +++ b/lib/pure/options.nim @@ -117,9 +117,10 @@ proc option*[T](val: sink T): Option[T] {.inline.} = assert option[Foo](nil).isNone assert option(42).isSome - result.val = val - when T isnot SomePointer: - result.has = true + when T is SomePointer: + result = Option[T](val: val) + else: + result = Option[T](has: true, val: val) proc some*[T](val: sink T): Option[T] {.inline.} = ## Returns an `Option` that has the value `val`. @@ -136,10 +137,9 @@ proc some*[T](val: sink T): Option[T] {.inline.} = when T is SomePointer: assert not val.isNil - result.val = val + result = Option[T](val: val) else: - result.has = true - result.val = val + result = Option[T](has: true, val: val) proc none*(T: typedesc): Option[T] {.inline.} = ## Returns an `Option` for this type that has no value. |