summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2020-05-25 14:31:02 +0100
committerGitHub <noreply@github.com>2020-05-25 15:31:02 +0200
commit6635874a8523d2140fb5dd7437904b985ddd5e59 (patch)
tree1ba32b2b14b42b26fd7e985fd3daa1f3ce0b9085 /lib
parent58282547f6d3fe4ce3fa2efe4f6afe07bc5de662 (diff)
downloadNim-6635874a8523d2140fb5dd7437904b985ddd5e59.tar.gz
make get for options use lent T (#14442)
Co-authored-by: cooldome <ariabushenko@bk.ru>
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/options.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim
index 0a20d3d73..5e68f9146 100644
--- a/lib/pure/options.nim
+++ b/lib/pure/options.nim
@@ -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.
   ##
@@ -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