1- ////===--- EitherSequence .swift - A sequence type-erasing two sequences -----===//
1+ ////===--- _EitherSequence .swift - A sequence type-erasing two sequences -----===//
22////
33//// This source file is part of the Swift.org open source project
44////
1212
1313// Not public stdlib API, currently used in Mirror.children implementation.
1414
15- internal enum Either < Left, Right> {
15+ internal enum _Either < Left, Right> {
1616 case left( Left ) , right( Right )
1717}
1818
19- extension Either {
19+ extension _Either {
2020 internal init ( _ left: Left , or other: Right . Type ) { self = . left( left) }
2121 internal init ( _ left: Left ) { self = . left( left) }
2222 internal init ( _ right: Right ) { self = . right( right) }
2323}
2424
25- extension Either : Equatable where Left: Equatable , Right: Equatable {
25+ extension _Either : Equatable where Left: Equatable , Right: Equatable {
2626 internal static func == ( lhs: Self , rhs: Self ) -> Bool {
2727 switch ( lhs, rhs) {
2828 case let ( . left( l) , . left( r) ) : return l == r
@@ -32,7 +32,7 @@ extension Either: Equatable where Left: Equatable, Right: Equatable {
3232 }
3333}
3434
35- extension Either : Comparable where Left: Comparable , Right: Comparable {
35+ extension _Either : Comparable where Left: Comparable , Right: Comparable {
3636 internal static func < ( lhs: Self , rhs: Self ) -> Bool {
3737 switch ( lhs, rhs) {
3838 case let ( . left( l) , . left( r) ) : return l < r
@@ -51,25 +51,25 @@ extension Either: Comparable where Left: Comparable, Right: Comparable {
5151/// AnySequence, giving you a fast path for the known one.
5252///
5353/// If you have 3+ types to erase, you can nest them.
54- typealias EitherSequence < L: Sequence , R: Sequence > =
55- Either < L , R > where L. Element == R. Element
54+ typealias _EitherSequence < L: Sequence , R: Sequence > =
55+ _Either < L , R > where L. Element == R. Element
5656
57- extension EitherSequence {
57+ extension _EitherSequence {
5858 internal struct Iterator {
5959 var left : Left . Iterator ?
6060 var right : Right . Iterator ?
6161 }
6262}
6363
64- extension Either . Iterator : IteratorProtocol {
64+ extension _Either . Iterator : IteratorProtocol {
6565 internal typealias Element = Left . Element
6666
6767 internal mutating func next( ) -> Element ? {
6868 left? . next ( ) ?? right? . next ( )
6969 }
7070}
7171
72- extension EitherSequence : Sequence {
72+ extension _EitherSequence : Sequence {
7373 internal typealias Element = Left . Element
7474
7575 internal func makeIterator( ) -> Iterator {
@@ -82,12 +82,12 @@ extension EitherSequence: Sequence {
8282 }
8383}
8484
85- internal typealias EitherCollection <
85+ internal typealias _EitherCollection <
8686 T: Collection , U: Collection
87- > = EitherSequence < T , U > where T. Element == U. Element
87+ > = _EitherSequence < T , U > where T. Element == U. Element
8888
89- extension EitherCollection : Collection {
90- internal typealias Index = Either < Left . Index , Right . Index >
89+ extension _EitherCollection : Collection {
90+ internal typealias Index = _Either < Left . Index , Right . Index >
9191
9292 internal var startIndex : Index {
9393 switch self {
@@ -107,15 +107,15 @@ extension EitherCollection: Collection {
107107 switch ( self , position) {
108108 case let ( . left( s) , . left( i) ) : return s [ i]
109109 case let ( . right( s) , . right( i) ) : return s [ i]
110- default : fatalError ( " EitherCollecton : Sequence used with other index type" )
110+ default : fatalError ( " _EitherCollecton : Sequence used with other index type" )
111111 }
112112 }
113113
114114 internal func index( after i: Index ) -> Index {
115115 switch ( self , i) {
116116 case let ( . left( s) , . left( i) ) : return . left( s. index ( after: i) )
117117 case let ( . right( s) , . right( i) ) : return . right( s. index ( after: i) )
118- default : fatalError ( " EitherCollecton : wrong type of index used" )
118+ default : fatalError ( " _EitherCollecton : wrong type of index used" )
119119 }
120120 }
121121
@@ -129,15 +129,15 @@ extension EitherCollection: Collection {
129129 return s. index ( i, offsetBy: distance, limitedBy: limit) . map { . left( $0) }
130130 case let ( . right( s) , . right( i) , . right( limit) ) :
131131 return s. index ( i, offsetBy: distance, limitedBy: limit) . map { . right( $0) }
132- default : fatalError ( " EitherCollecton : wrong type of index used" )
132+ default : fatalError ( " _EitherCollecton : wrong type of index used" )
133133 }
134134 }
135135
136136 internal func index( _ i: Index , offsetBy distance: Int ) -> Index {
137137 switch ( self , i) {
138138 case let ( . left( s) , . left( i) ) : return . left( s. index ( i, offsetBy: distance) )
139139 case let ( . right( s) , . right( i) ) : return . right( s. index ( i, offsetBy: distance) )
140- default : fatalError ( " EitherCollecton : wrong type of index used" )
140+ default : fatalError ( " _EitherCollecton : wrong type of index used" )
141141 }
142142 }
143143
@@ -147,32 +147,32 @@ extension EitherCollection: Collection {
147147 return s. distance ( from: i, to: j)
148148 case let ( . right( s) , . right( i) , . right( j) ) :
149149 return s. distance ( from: i, to: j)
150- default : fatalError ( " EitherCollecton : wrong type of index used" )
150+ default : fatalError ( " _EitherCollecton : wrong type of index used" )
151151 }
152152 }
153153}
154154
155- internal typealias EitherBidirectionalCollection <
155+ internal typealias _EitherBidirectionalCollection <
156156 L: BidirectionalCollection , R: BidirectionalCollection
157- > = Either < L , R > where L. Element == R. Element
157+ > = _Either < L , R > where L. Element == R. Element
158158
159- extension EitherBidirectionalCollection : BidirectionalCollection {
159+ extension _EitherBidirectionalCollection : BidirectionalCollection {
160160 internal func index( before i: Index ) -> Index {
161161 switch ( self , i) {
162162 case let ( . left( s) , . left( i) ) : return . left( s. index ( before: i) )
163163 case let ( . right( s) , . right( i) ) : return . right( s. index ( before: i) )
164- default : fatalError ( " EitherCollecton : wrong type of index used" )
164+ default : fatalError ( " _EitherCollecton : wrong type of index used" )
165165 }
166166 }
167167}
168168
169- internal typealias EitherRandomAccessCollection <
169+ internal typealias _EitherRandomAccessCollection <
170170 L: RandomAccessCollection , R: RandomAccessCollection
171- > = Either < L , R > where L. Element == R. Element
171+ > = _Either < L , R > where L. Element == R. Element
172172
173- extension EitherRandomAccessCollection : RandomAccessCollection { }
173+ extension _EitherRandomAccessCollection : RandomAccessCollection { }
174174
175- extension Either {
175+ extension _Either {
176176 init < T, C: Collection > (
177177 _ collection: C
178178 ) where Right == AnyCollection < T > , C. Element == T {
@@ -182,7 +182,7 @@ extension Either {
182182
183183extension AnyCollection {
184184 init < L: Collection , R: Collection > (
185- _ other: Either < L , R >
185+ _ other: _Either < L , R >
186186 ) where L. Element == Element , R. Element == Element {
187187 // Strip away the Either and put the actual collection into the existential,
188188 // trying to use the custom initializer from another AnyCollection.
0 commit comments