File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 11
22import os. lock
33
4- /**
5- non-atomic
6- */
4+ @dynamicMemberLookup
75public final class _BackingStorage < Value> : Sendable {
86
97 public var value : Value {
@@ -21,6 +19,24 @@ public final class _BackingStorage<Value>: Sendable {
2119
2220 private let _value : ManagedCriticalState < Value >
2321
22+ public subscript < U> ( dynamicMember keyPath: KeyPath < Value , U > ) -> U {
23+ _read { yield value [ keyPath: keyPath] }
24+ }
25+
26+ public subscript < U> ( dynamicMember keyPath: KeyPath < Value , U ? > ) -> U ? {
27+ _read { yield value [ keyPath: keyPath] }
28+ }
29+
30+ public subscript < U> ( dynamicMember keyPath: WritableKeyPath < Value , U > ) -> U {
31+ _read { yield value [ keyPath: keyPath] }
32+ _modify { yield & value[ keyPath: keyPath] }
33+ }
34+
35+ public subscript < U> ( dynamicMember keyPath: WritableKeyPath < Value , U ? > ) -> U ? {
36+ _read { yield value [ keyPath: keyPath] }
37+ _modify { yield & value[ keyPath: keyPath] }
38+ }
39+
2440 public init ( _ value: consuming Value ) {
2541 self . _value = . init( value)
2642 }
You can’t perform that action at this time.
0 commit comments