@@ -466,106 +466,6 @@ ${orderingExplanation}
466
466
}
467
467
}
468
468
469
- % for Self in '_Indexable', '_MutableIndexable':
470
- % {
471
-
472
- subscriptCommentPre = """ \
473
- /// Accesses a contiguous subrange of the collection's elements.
474
- ///
475
- /// The accessed slice uses the same indices for the same elements as the
476
- /// original collection. Always use the slice's `startIndex` property
477
- /// instead of assuming that its indices start at a particular value.
478
- ///
479
- /// This example demonstrates getting a slice of an array of strings, finding
480
- /// the index of one of the strings in the slice, and then using that index
481
- /// in the original array.
482
- ///
483
- /// let streets = [ " Adams " , " Bryant " , " Channing " , " Douglas " , " Evarts " ]
484
- /// let streetsSlice = streets[2 ..< streets.endIndex]
485
- /// print(streetsSlice)
486
- /// // Prints " [ " Channing " , " Douglas " , " Evarts " ] "
487
- ///
488
- /// let index = streetsSlice.index(of: " Evarts " ) // 4 """
489
-
490
- if 'Mutable' in Self:
491
- subscriptCommentMid = """ \
492
- /// streets[index!] = " Eustace "
493
- /// print(streets[index!])
494
- /// // Prints " Eustace \" """
495
- else:
496
- subscriptCommentMid = """ \
497
- /// print(streets[index!])
498
- /// // Prints " Evarts \" """
499
-
500
- subscriptCommentPost = """ \
501
- ///
502
- /// - Parameter bounds: A range of the collection's indices. The bounds of
503
- /// the range must be valid indices of the collection. """
504
- } %
505
- // FIXME(ABI)#180 (Type checker)
506
- // WORKAROUND rdar://25214066 - should be on Collection
507
- extension ${ Self} {
508
- ${ subscriptCommentPre}
509
- ${ subscriptCommentMid}
510
- ${ subscriptCommentPost}
511
- @_inlineable
512
- public subscript( bounds: ClosedRange < Index > ) -> SubSequence {
513
- get {
514
- return self [
515
- Range (
516
- uncheckedBounds: (
517
- lower: bounds. lowerBound,
518
- upper: index ( after: bounds. upperBound) ) )
519
- ]
520
- }
521
- % if 'Mutable' in Self:
522
- set {
523
- self [
524
- Range (
525
- uncheckedBounds: (
526
- lower: bounds. lowerBound,
527
- upper: index ( after: bounds. upperBound) ) )
528
- ] = newValue
529
- }
530
- % end
531
- }
532
- }
533
-
534
- // FIXME(ABI)#180 (Type checker)
535
- // WORKAROUND rdar://25214066 - should be on Collection
536
- extension ${ Self} where Index : Strideable, Index . Stride : SignedInteger {
537
- ${ subscriptCommentPre}
538
- ${ subscriptCommentMid}
539
- ${ subscriptCommentPost}
540
- @_inlineable
541
- public subscript( bounds: CountableRange < Index > ) -> SubSequence {
542
- get {
543
- return self [ Range ( bounds) ]
544
- }
545
- % if 'Mutable' in Self:
546
- set {
547
- self [ Range ( bounds) ] = newValue
548
- }
549
- % end
550
- }
551
-
552
- ${ subscriptCommentPre}
553
- ${ subscriptCommentMid}
554
- ${ subscriptCommentPost}
555
- @_inlineable
556
- public subscript( bounds: CountableClosedRange < Index > ) -> SubSequence {
557
- get {
558
- return self [ ClosedRange ( bounds) ]
559
- }
560
- % if 'Mutable' in Self:
561
- set {
562
- self [ ClosedRange ( bounds) ] = newValue
563
- }
564
- % end
565
- }
566
- }
567
- % end
568
-
569
469
//===--- Unavailable stuff ------------------------------------------------===//
570
470
571
471
extension MutableCollection where Self : RandomAccessCollection {
0 commit comments