diff --git a/lib/pure/options.nim b/lib/pure/options.nim index b34ff72c0dfb..59a580ccde5f 100644 --- a/lib/pure/options.nim +++ b/lib/pure/options.nim @@ -379,3 +379,12 @@ proc unsafeGet*[T](self: Option[T]): lent T {.inline.}= ## Generally, using the `get proc <#get,Option[T]>`_ is preferred. assert self.isSome result = self.val + +proc unsafeGet*[T](self: var Option[T]): var T {.inline.}= + ## Returns the value of a `some` mutably. The behavior is undefined for `none`. + ## + ## **Note:** Use this only when you are **absolutely sure** the value is present + ## (e.g. after checking with `isSome <#isSome,Option[T]>`_). + ## Generally, using the `get proc <#get,Option[T]_2>`_ is preferred. + assert self.isSome + result = self.val