@@ -25,7 +25,9 @@ public protocol RangeExpression {
25
25
/// its bounds. Callers should apply the same preconditions
26
26
/// to the return value as they would to a range provided
27
27
/// directly by the user.
28
- func relative< C: _Indexable > ( to collection: C ) -> Range < Bound > where C. Index == Bound
28
+ func relative< C: _Indexable > (
29
+ to collection: C
30
+ ) -> Range < Bound > where C. Index == Bound
29
31
30
32
func contains( _ element: Bound ) -> Bool
31
33
}
@@ -37,8 +39,8 @@ extension RangeExpression {
37
39
}
38
40
}
39
41
40
- // FIXME(ABI)#55 (Statically Unavailable/Dynamically Available): remove this type, it creates an ABI burden
41
- // on the library.
42
+ // FIXME(ABI)#55 (Statically Unavailable/Dynamically Available): remove this
43
+ // type, it creates an ABI burden on the library.
42
44
//
43
45
// A dummy type that we can use when we /don't/ want to create an
44
46
// ambiguity indexing CountableRange<T> outside a generic context.
@@ -241,8 +243,8 @@ public struct CountableRange<Bound> : RandomAccessCollection
241
243
// such as x = r[0], which will trap unless 0 happens to be contained in the
242
244
// range r.
243
245
//
244
- // FIXME(ABI)#56 (Statically Unavailable/Dynamically Available): remove this code, it creates an ABI burden
245
- // on the library.
246
+ // FIXME(ABI)#56 (Statically Unavailable/Dynamically Available): remove this
247
+ // code, it creates an ABI burden on the library.
246
248
extension CountableRange {
247
249
/// Accesses the element at specified position.
248
250
///
@@ -432,7 +434,8 @@ def get_init_warning(Self, OtherSelf):
432
434
% for ( Self, op) in all_range_types:
433
435
% for (OtherSelf, other_op) in all_range_types:
434
436
extension ${ Self}
435
- % if ( 'Countable' in OtherSelf or 'Closed' in OtherSelf or 'Closed' in Self) and not 'Countable' in Self:
437
+ % if ( 'Countable' in OtherSelf or 'Closed' in OtherSelf or 'Closed' in Self) \
438
+ % and not 'Countable' in Self:
436
439
where
437
440
Bound : _Strideable, Bound . Stride : SignedInteger
438
441
% end
@@ -541,14 +544,15 @@ extension ${Self} {
541
544
}
542
545
543
546
extension ${ Self} : RangeExpression {
544
- public func relative< C : _Indexable > ( to collection: C) - > Range< Bound> where C. Index == Bound {
547
+ public func relative< C : _Indexable > ( to collection: C) - > Range< Bound>
548
+ where C. Index == Bound {
545
549
% if 'Closed' in Self:
546
- return Range( uncheckedBounds:
547
- ( lower: lowerBound, upper: collection. index ( after: self . upperBound) )
550
+ return Range (
551
+ uncheckedBounds: (
552
+ lower: lowerBound, upper: collection. index ( after: self . upperBound) ) )
548
553
% else :
549
- return Range ( uncheckedBounds: ( lower: lowerBound, upper: upperBound)
554
+ return Range ( uncheckedBounds: ( lower: lowerBound, upper: upperBound) )
550
555
% end
551
- )
552
556
}
553
557
}
554
558
@@ -656,8 +660,8 @@ extension ${Self} : Equatable {
656
660
% 'Range',
657
661
% 'ClosedRange',
658
662
% ] :
659
- // FIXME(ABI)#57 (Conditional Conformance): replace this extension with a conditional
660
- // conformance.
663
+ // FIXME(ABI)#57 (Conditional Conformance): replace this extension with a
664
+ // conditional conformance.
661
665
// rdar://problem/17144340
662
666
/// Ranges whose `Bound` is `Strideable` with `Integer` `Stride` have all
663
667
/// the capabilities of `RandomAccessCollection`s, just like
@@ -739,23 +743,30 @@ public func ..< <Bound>(
739
743
@_fixed_layout
740
744
public struct PartialRangeUpTo < Bound: Comparable > : RangeExpression {
741
745
public init ( _ upperBound: Bound ) { self . upperBound = upperBound }
746
+
742
747
public let upperBound : Bound
748
+
743
749
@_transparent
744
- public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound > where C. Index == Bound {
750
+ public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound >
751
+ where C. Index == Bound {
745
752
return collection. startIndex..< self . upperBound
746
753
}
754
+
747
755
@_transparent
748
756
public func contains( _ element: Bound ) -> Bool {
749
757
return element < upperBound
750
758
}
751
759
}
752
760
753
761
@_fixed_layout
754
- public struct PartialRangeThrough < Bound: Comparable > : RangeExpression {
762
+ public struct PartialRangeThrough < Bound: Comparable > : RangeExpression {
755
763
public init ( _ upperBound: Bound ) { self . upperBound = upperBound }
764
+
756
765
public let upperBound : Bound
766
+
757
767
@_transparent
758
- public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound > where C. Index == Bound {
768
+ public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound >
769
+ where C. Index == Bound {
759
770
return collection. startIndex..< collection. index ( after: self . upperBound)
760
771
}
761
772
@_transparent
@@ -767,11 +778,15 @@ public struct PartialRangeThrough<Bound: Comparable>: RangeExpression {
767
778
@_fixed_layout
768
779
public struct PartialRangeFrom < Bound: Comparable > : RangeExpression {
769
780
public init ( _ lowerBound: Bound ) { self . lowerBound = lowerBound }
781
+
770
782
public let lowerBound : Bound
783
+
771
784
@_transparent
772
- public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound > where C. Index == Bound {
785
+ public func relative< C: _Indexable > ( to collection: C ) -> Range < Bound >
786
+ where C. Index == Bound {
773
787
return self . lowerBound..< collection. endIndex
774
788
}
789
+
775
790
@_transparent
776
791
public func contains( _ element: Bound ) -> Bool {
777
792
return lowerBound <= element
@@ -908,20 +923,23 @@ extension Strideable where Stride: SignedInteger {
908
923
/// - Parameters:
909
924
/// - minimum: The lower bound for the range.
910
925
@_transparent
911
- public static postfix func ... ( minimum: Self) -> CountablePartialRangeFrom< Self> {
912
- return CountablePartialRangeFrom( minimum)
926
+ public static postfix func ... ( minimum: Self)
927
+ -> CountablePartialRangeFrom< Self> {
928
+ return CountablePartialRangeFrom( minimum)
913
929
}
914
930
}
915
931
916
932
extension _Indexable {
917
933
@_inlineable
918
- public subscript< R: RangeExpression > ( r: R ) -> SubSequence where R. Bound == Index {
934
+ public subscript< R: RangeExpression > ( r: R )
935
+ -> SubSequence where R. Bound == Index {
919
936
return self [ r. relative ( to: self ) ]
920
937
}
921
938
}
922
939
extension _MutableIndexable {
923
940
@_inlineable
924
- public subscript< R: RangeExpression > ( r: R ) -> SubSequence where R. Bound == Index {
941
+ public subscript< R: RangeExpression > ( r: R ) -> SubSequence
942
+ where R. Bound == Index {
925
943
get {
926
944
return self [ r. relative ( to: self ) ]
927
945
}
0 commit comments