Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make get for options use lent T #14442

Merged
merged 1 commit into from
May 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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