diff --git a/Sources/With.swift b/Sources/With.swift index 1f9c956..2bb6d59 100644 --- a/Sources/With.swift +++ b/Sources/With.swift @@ -24,10 +24,11 @@ public func with(_ 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(_ subject:SubjectT, operations:(SubjectT) throws -> ReturnT) +public func with(_ subject:SubjectT, operations:(inout SubjectT) throws -> ReturnT) rethrows -> ReturnT { - return try operations(subject) + var subject = subject + return try operations(&subject) }