title: Custom assignment operator with inout closure
body: <p>I'm trying to write a custom assignment operator in Swift 3 that will allow me to set a variable and update its properties all at once. Like so,</p>
  
  <pre><code>protocol BatchSettable { }
  
  infix operator =&lt;
  
  public func =&lt; &lt;T: BatchSettable&gt;(lhs: inout T?, rhs: (inout T) -&gt; Void) {
      if var copy = lhs {
          rhs(&amp;copy)
          lhs = copy
      } else {
          lhs = nil
      }
  }
  </code></pre>
  
  <p>This would, in theory, allow me to write</p>
  
  <pre><code>struct MyStruct: BatchSettable {
      var someBoolProperty: Bool?
      var someStringProperty: String?
  }
  
  self.myStruct =&lt; {
      $0.someBoolProperty = false
      $0.someStringProperty = "someString"
  }
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>var myVar = self.myStruct
  myVar.someBoolProperty = false
  myVar.someStringProperty = "someString"
  self.myStruct = myVar
  </code></pre>
  
  <p>My intention here is to be able to update multiple fields on a value-type property (struct) without triggering <code>didSet</code> multiple times.</p>
  
  <p>The operator itself compiles with no errors, but when I try to use it I get</p>
  
  <pre><code>Cannot assign to property: '$0' is immutable
  </code></pre>
  
  <p>Any ideas?</p>