Skip to content

Commit

Permalink
Fix: Made arbitrary-return version use inout too
Browse files Browse the repository at this point in the history
Swift's type inference gets really confused otherwise, erroring with “Ambiguous use of 'with(_:operations:)`”.  Not sure why, but as before, having the args _exactly_ the same between all the overloads solves it.
  • Loading branch information
capnslipp committed Mar 6, 2020
1 parent b8336d2 commit 5f14777
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/With.swift
Expand Up @@ -24,10 +24,11 @@ public func with<SubjectT:AnyObject>(_ subject:SubjectT, operations:(inout Subje

/// “With” on an reference-type (object) subject, returning an aribitrary return value from the closure (the subject is still mutated).
@inlinable
public func with<SubjectT:AnyObject, ReturnT>(_ subject:SubjectT, operations:(SubjectT) throws -> ReturnT)
public func with<SubjectT:AnyObject, ReturnT:Any>(_ subject:SubjectT, operations:(inout SubjectT) throws -> ReturnT)
rethrows -> ReturnT
{
return try operations(subject)
var subject = subject
return try operations(&subject)
}


Expand Down

0 comments on commit 5f14777

Please sign in to comment.