[Pitch] `With` functions in the standard library

My point is that the design of this feature should take into account all semantics the language is capable of. It can't be achieved with just one function.
We should address the following:

  1. Copy?
  • Yes
  • No
  1. Type of modifier
  • Mutating
  • Consuming
  • Borrowing
  1. Result
  • No result
  • Result of transformation (defined by the closure)
  • Original value (or copy).

It would also be wonderful if there will be a way to guarantee that the closure will be executed exactly once and in the same callstack.

I described it all in my proposal about do blocks, checkout the section 3.

1 Like