@@ -75,30 +75,30 @@ extension Case {
75
75
let keyPath = keyPath. unsafeSendable ( )
76
76
return Case < AppendedValue > (
77
77
embed: {
78
- embed ( Value . allCasePaths [ keyPath: keyPath] . embed ( $0) )
78
+ _embed ( Value . allCasePaths [ keyPath: keyPath] . embed ( $0) )
79
79
} ,
80
80
extract: {
81
- extract ( from: $0) . flatMap ( Value . allCasePaths [ keyPath: keyPath] . extract)
81
+ _extract ( from: $0) . flatMap ( Value . allCasePaths [ keyPath: keyPath] . extract)
82
82
}
83
83
)
84
84
}
85
85
86
- public func embed ( _ value: Value ) -> Any {
86
+ public func _embed ( _ value: Value ) -> Any {
87
87
self . _embed ( value)
88
88
}
89
89
90
- public func extract ( from root: Any ) -> Value ? {
90
+ public func _extract ( from root: Any ) -> Value ? {
91
91
self . _extract ( root)
92
92
}
93
93
}
94
94
95
95
private protocol _AnyCase {
96
- func _extract ( from root: Any ) -> Any ?
96
+ func extractAny ( from root: Any ) -> Any ?
97
97
}
98
98
99
99
extension Case : _AnyCase {
100
- fileprivate func _extract ( from root: Any ) -> Any ? {
101
- self . extract ( from: root)
100
+ fileprivate func extractAny ( from root: Any ) -> Any ? {
101
+ self . _extract ( from: root)
102
102
}
103
103
}
104
104
@@ -202,7 +202,7 @@ extension CaseKeyPath {
202
202
/// - Returns: An enum for the case of this key path that holds the given value.
203
203
public func callAsFunction< Enum, AssociatedValue> ( _ value: AssociatedValue ) -> Enum
204
204
where Root == Case < Enum > , Value == Case < AssociatedValue > {
205
- Case ( self ) . embed ( value) as! Enum
205
+ Case ( self ) . _embed ( value) as! Enum
206
206
}
207
207
208
208
/// Returns an enum for this case key path's case.
@@ -227,7 +227,7 @@ extension CaseKeyPath {
227
227
/// - Returns: An enum for the case of this key path.
228
228
public func callAsFunction< Enum> ( ) -> Enum
229
229
where Root == Case < Enum > , Value == Case < Void > {
230
- Case ( self ) . embed ( ( ) ) as! Enum
230
+ Case ( self ) . _embed ( ( ) ) as! Enum
231
231
}
232
232
233
233
/// Whether an argument matches the case key path's case.
@@ -280,8 +280,8 @@ extension _AppendKeyPath {
280
280
) -> Enum ?
281
281
where Self == PartialCaseKeyPath < Enum > {
282
282
func open< AnyAssociatedValue> ( _ value: AnyAssociatedValue ) -> Enum ? {
283
- ( Case < Enum > ( ) [ keyPath: self ] as? Case < AnyAssociatedValue > ) ? . embed ( value) as? Enum
284
- ?? ( Case < Enum > ( ) [ keyPath: self ] as? Case < AnyAssociatedValue ? > ) ? . embed ( value) as? Enum
283
+ ( Case < Enum > ( ) [ keyPath: self ] as? Case < AnyAssociatedValue > ) ? . _embed ( value) as? Enum
284
+ ?? ( Case < Enum > ( ) [ keyPath: self ] as? Case < AnyAssociatedValue ? > ) ? . _embed ( value) as? Enum
285
285
}
286
286
return _openExistential ( value, do: open)
287
287
}
@@ -324,13 +324,13 @@ extension CasePathable {
324
324
/// enum, and see ``Swift/KeyPath/callAsFunction(_:)`` for embedding an associated value in a
325
325
/// brand new root enum.
326
326
public subscript< Value> ( case keyPath: CaseKeyPath < Self , Value > ) -> Value ? {
327
- Case ( keyPath) . extract ( from: self )
327
+ Case ( keyPath) . _extract ( from: self )
328
328
}
329
329
330
330
/// Attempts to extract the associated value from a root enum using a partial case key path.
331
331
@_disfavoredOverload
332
332
public subscript( case keyPath: PartialCaseKeyPath < Self > ) -> Any ? {
333
- ( Case < Self > ( ) [ keyPath: keyPath] as? any _AnyCase ) ? . _extract ( from: self )
333
+ ( Case < Self > ( ) [ keyPath: keyPath] as? any _AnyCase ) ? . extractAny ( from: self )
334
334
}
335
335
336
336
/// Replaces the associated value of a root enum at a case key path when the case matches.
@@ -362,8 +362,8 @@ extension CasePathable {
362
362
get { fatalError ( ) }
363
363
set {
364
364
let `case` = Case ( keyPath)
365
- guard `case`. extract ( from: self ) != nil else { return }
366
- self = `case`. embed ( newValue) as! Self
365
+ guard `case`. _extract ( from: self ) != nil else { return }
366
+ self = `case`. _embed ( newValue) as! Self
367
367
}
368
368
}
369
369
@@ -475,7 +475,7 @@ extension CasePathable {
475
475
column: UInt = #column
476
476
) {
477
477
let `case` = Case ( keyPath)
478
- guard var value = `case`. extract ( from: self ) else {
478
+ guard var value = `case`. _extract ( from: self ) else {
479
479
reportIssue (
480
480
"""
481
481
Can't modify ' \( String ( describing: self ) ) ' via 'CaseKeyPath< \( Self . self) , \( Value . self) >' \
@@ -489,7 +489,7 @@ extension CasePathable {
489
489
return
490
490
}
491
491
yield( & value)
492
- self = `case`. embed ( value) as! Self
492
+ self = `case`. _embed ( value) as! Self
493
493
}
494
494
}
495
495
@@ -500,8 +500,8 @@ extension AnyCasePath {
500
500
public init ( _ keyPath: CaseKeyPath < Root , Value > ) {
501
501
let `case` = Case ( keyPath)
502
502
self . init (
503
- embed: { `case`. embed ( $0) as! Root } ,
504
- extract: { `case`. extract ( from: $0) }
503
+ embed: { `case`. _embed ( $0) as! Root } ,
504
+ extract: { `case`. _extract ( from: $0) }
505
505
)
506
506
}
507
507
}
0 commit comments