Use more lent in options (#15208)

This commit is contained in:
Mamy Ratsimbazafy 2020-08-24 08:05:17 +02:00 • committed by GitHub
commit 07d82b5cc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -363,14 +363,14 @@ proc `$`*[T](self: Option[T]): string =
else:
result = "None[" & name(T) & "]"
proc unsafeGet*[T](self: Option[T]): T {.inline.}=
proc unsafeGet*[T](self: Option[T]): lent T {.inline.}=
## Returns the value of a `some`. Behavior is undefined for `none`.
##
## **Note:** Use it only when you are **absolutely sure** the value is present
## (e.g. after checking `isSome <#isSome,Option[T]>`_).
## Generally, using `get proc <#get,Option[T]>`_ is preferred.
assert self.isSome
self.val
result = self.val
when isMainModule: