File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Sources/FunctionalBuilder Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 11import FunctionalConfigurator
22import FunctionalKeyPath
3+ import FunctionalModification
34
45@dynamicMemberLookup
56public struct Builder < Base> {
@@ -129,7 +130,11 @@ extension Builder {
129130 Builder (
130131 _block. builder. _initialValue,
131132 _block. builder. _configurator. appendingConfiguration { base in
132- _block. keyPath. embed ( value ( ) , in: base)
133+ if condition {
134+ return _block. keyPath. embed ( value ( ) , in: base)
135+ } else {
136+ return base
137+ }
133138 }
134139 )
135140 }
@@ -143,6 +148,18 @@ extension Builder {
143148 )
144149 }
145150
151+ public func set( _ transform: @escaping ( inout Value ) -> Void ) -> Builder {
152+ Builder (
153+ _block. builder. _initialValue,
154+ _block. builder. _configurator. appendingConfiguration { base in
155+ _block. keyPath. embed (
156+ modification ( of: _block. keyPath. extract ( from: base) , with: transform) ,
157+ in: base
158+ )
159+ }
160+ )
161+ }
162+
146163 public subscript< LocalValue> (
147164 dynamicMember keyPath: WritableKeyPath < Value , LocalValue >
148165 ) -> CallableBlock < LocalValue > {
You can’t perform that action at this time.
0 commit comments