From 3f18804608ad52856f31e7425ecc4a907c7ffe1c Mon Sep 17 00:00:00 2001 From: cooldome Date: Sun, 24 May 2020 22:50:40 +0100 Subject: [PATCH] make get for options use lent T --- lib/pure/options.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/options.nim b/lib/pure/options.nim index 0a20d3d732c5..5e68f9146d5a 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