superfunc/maybe

Consider Allowing Mutable Destructure

Closed this issue · 1 comments

Currently, the bound values in a pattern match are copies, they could be mutable references to the contained value.

Something like:

maybeCase m:
  just x:
    x = x + 1
  nothing:
    discard

desugars to

if m.isValid:
  var x = addr m.value
  x[] = x[] + 1
else:
  discard