Skip to content

Commit

Permalink
make get for options use lent T (#14442)
Browse files Browse the repository at this point in the history
Co-authored-by: cooldome <[email protected]>
  • Loading branch information
cooldome and cooldome authored May 25, 2020
1 parent 5828254 commit 6635874
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pure/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ proc isNone*[T](self: Option[T]): bool {.inline.} =
else:
not self.has

proc get*[T](self: Option[T]): T {.inline.} =
proc get*[T](self: Option[T]): lent T {.inline.} =
## Returns contents of an `Option`. If it is `None`, then an exception is
## thrown.
##
Expand All @@ -183,7 +183,7 @@ proc get*[T](self: Option[T]): T {.inline.} =

if self.isNone:
raise newException(UnpackError, "Can't obtain a value from a `none`")
self.val
result = self.val

proc get*[T](self: Option[T], otherwise: T): T {.inline.} =
## Returns the contents of the `Option` or an `otherwise` value if
Expand Down

0 comments on commit 6635874

Please sign in to comment.