From 8b6b3b0231e36e9174c849b540822365adfdbce1 Mon Sep 17 00:00:00 2001 From: Hiroshi Kimura Date: Thu, 22 Aug 2024 15:44:51 +0900 Subject: [PATCH] Update modify operator (#4) --- Sources/Wrap/Wrap.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Wrap/Wrap.swift b/Sources/Wrap/Wrap.swift index 42a1e35..842c0f9 100644 --- a/Sources/Wrap/Wrap.swift +++ b/Sources/Wrap/Wrap.swift @@ -12,7 +12,7 @@ public func <& (argument: inout T, modifier: (inout T) throws -> Void) rethro public struct _FlowDownBox: ~Copyable { - public let value: Value + public var value: Value public init(_ value: consuming Value) { self.value = consume value @@ -44,9 +44,8 @@ extension _FlowDownBox { } public consuming func modify(_ modifier: (inout Value) throws -> Void) rethrows -> Value { - var v = value - try modifier(&v) - return v + try modifier(&value) + return value } public consuming func filter(_ filter: (consuming Value) -> Bool) -> Value? {