diff options
author | alaviss <alaviss@users.noreply.github.com> | 2018-05-06 15:55:19 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-06 10:55:19 +0200 |
commit | 26d89fa09c3a214c9c2107367c3d3fd76f7b8e1c (patch) | |
tree | ca53e552f00bf424954283d6da08f78d621bd38d /lib/pure | |
parent | d8dd43e5003d407d105ee9b6f9f2c6f4f45902d8 (diff) | |
download | Nim-26d89fa09c3a214c9c2107367c3d3fd76f7b8e1c.tar.gz |
options: use isSome (#7782)
Fixes #7780
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/options.nim | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim index aaffb57ca..bd01b208a 100644 --- a/lib/pure/options.nim +++ b/lib/pure/options.nim @@ -134,7 +134,7 @@ proc get*[T](self: Option[T]): T = proc get*[T](self: Option[T], otherwise: T): T = ## Returns the contents of this option or `otherwise` if the option is none. - if self.has: + if self.isSome: self.val else: otherwise @@ -154,7 +154,7 @@ proc map*[T, R](self: Option[T], callback: proc (input: T): R): Option[R] = proc flatten*[A](self: Option[Option[A]]): Option[A] = ## Remove one level of structure in a nested Option. - if self.has: + if self.isSome: self.val else: none(A) @@ -179,14 +179,14 @@ proc filter*[T](self: Option[T], callback: proc (input: T): bool): Option[T] = proc `==`*(a, b: Option): bool = ## Returns ``true`` if both ``Option``s are ``none``, ## or if they have equal values - (a.has and b.has and a.val == b.val) or (not a.has and not b.has) + (a.isSome and b.isSome and a.val == b.val) or (not a.isSome and not b.isSome) proc `$`*[T](self: Option[T]): string = ## Get the string representation of this option. If the option has a value, ## the result will be `Some(x)` where `x` is the string representation of the contained value. ## If the option does not have a value, the result will be `None[T]` where `T` is the name of ## the type contained in the option. - if self.has: + if self.isSome: "Some(" & $self.val & ")" else: "None[" & T.name & "]" |