@@ -536,13 +536,20 @@ extension Span where Element: ~Copyable {
536
536
/// - Complexity: O(1)
537
537
@_alwaysEmitIntoClient
538
538
@lifetime ( copy self)
539
- public func _extracting ( _ bounds: Range < Index > ) -> Self {
539
+ public func extracting ( _ bounds: Range < Index > ) -> Self {
540
540
_precondition (
541
541
UInt ( bitPattern: bounds. lowerBound) <= UInt ( bitPattern: _count) &&
542
542
UInt ( bitPattern: bounds. upperBound) <= UInt ( bitPattern: _count) ,
543
543
" Index range out of bounds "
544
544
)
545
- return unsafe _extracting( unchecked: bounds)
545
+ return unsafe extracting( unchecked: bounds)
546
+ }
547
+
548
+ @available ( * , deprecated, renamed: " extracting(_:) " )
549
+ @_alwaysEmitIntoClient
550
+ @lifetime ( copy self)
551
+ public func _extracting( _ bounds: Range < Index > ) -> Self {
552
+ extracting ( bounds)
546
553
}
547
554
548
555
/// Constructs a new span over the items within the supplied range of
@@ -563,7 +570,7 @@ extension Span where Element: ~Copyable {
563
570
@unsafe
564
571
@_alwaysEmitIntoClient
565
572
@lifetime ( copy self)
566
- public func _extracting ( unchecked bounds: Range < Index > ) -> Self {
573
+ public func extracting ( unchecked bounds: Range < Index > ) -> Self {
567
574
let delta = bounds. lowerBound &* MemoryLayout< Element> . stride
568
575
let newStart = unsafe _pointer? . advanced ( by: delta)
569
576
let newSpan = unsafe Span( _unchecked: newStart, count: bounds. count)
@@ -572,6 +579,14 @@ extension Span where Element: ~Copyable {
572
579
return unsafe _override Lifetime ( newSpan, copying: self )
573
580
}
574
581
582
+ @unsafe
583
+ @available ( * , deprecated, renamed: " extracting(unchecked:) " )
584
+ @_alwaysEmitIntoClient
585
+ @lifetime ( copy self)
586
+ public func _extracting( unchecked bounds: Range < Index > ) -> Self {
587
+ unsafe extracting( unchecked: bounds)
588
+ }
589
+
575
590
/// Constructs a new span over the items within the supplied range of
576
591
/// positions within this span.
577
592
///
@@ -587,10 +602,17 @@ extension Span where Element: ~Copyable {
587
602
/// - Complexity: O(1)
588
603
@_alwaysEmitIntoClient
589
604
@lifetime ( copy self)
590
- public func _extracting (
605
+ public func extracting (
591
606
_ bounds: some RangeExpression < Index >
592
607
) -> Self {
593
- _extracting ( bounds. relative ( to: indices) )
608
+ extracting ( bounds. relative ( to: indices) )
609
+ }
610
+
611
+ @available ( * , deprecated, renamed: " extracting(_:) " )
612
+ @_alwaysEmitIntoClient
613
+ @lifetime ( copy self)
614
+ public func _extracting( _ bounds: some RangeExpression < Index > ) -> Self {
615
+ extracting ( bounds)
594
616
}
595
617
596
618
/// Constructs a new span over the items within the supplied range of
@@ -611,13 +633,21 @@ extension Span where Element: ~Copyable {
611
633
@unsafe
612
634
@_alwaysEmitIntoClient
613
635
@lifetime ( copy self)
614
- public func _extracting (
636
+ public func extracting (
615
637
unchecked bounds: ClosedRange < Index >
616
638
) -> Self {
617
639
let range = unsafe Range(
618
640
_uncheckedBounds: ( bounds. lowerBound, bounds. upperBound + 1 )
619
641
)
620
- return unsafe _extracting( unchecked: range)
642
+ return unsafe extracting( unchecked: range)
643
+ }
644
+
645
+ @unsafe
646
+ @available ( * , deprecated, renamed: " extracting(unchecked:) " )
647
+ @_alwaysEmitIntoClient
648
+ @lifetime ( copy self)
649
+ public func _extracting( unchecked bounds: ClosedRange < Index > ) -> Self {
650
+ unsafe extracting( unchecked: bounds)
621
651
}
622
652
623
653
/// Constructs a new span over all the items of this span.
@@ -631,6 +661,13 @@ extension Span where Element: ~Copyable {
631
661
/// - Complexity: O(1)
632
662
@_alwaysEmitIntoClient
633
663
@lifetime ( copy self)
664
+ public func extracting( _: UnboundedRange ) -> Self {
665
+ self
666
+ }
667
+
668
+ @available ( * , deprecated, renamed: " extracting(_:) " )
669
+ @_alwaysEmitIntoClient
670
+ @lifetime ( copy self)
634
671
public func _extracting( _: UnboundedRange ) -> Self {
635
672
self
636
673
}
@@ -761,13 +798,20 @@ extension Span where Element: ~Copyable {
761
798
/// - Complexity: O(1)
762
799
@_alwaysEmitIntoClient
763
800
@lifetime ( copy self)
764
- public func _extracting ( first maxLength: Int ) -> Self {
801
+ public func extracting ( first maxLength: Int ) -> Self {
765
802
_precondition ( maxLength >= 0 , " Can't have a prefix of negative length " )
766
803
let newCount = min ( maxLength, count)
767
804
let newSpan = unsafe Self( _unchecked: _pointer, count: newCount)
768
805
return unsafe _override Lifetime ( newSpan, copying: self )
769
806
}
770
807
808
+ @available ( * , deprecated, renamed: " extracting(first:) " )
809
+ @_alwaysEmitIntoClient
810
+ @lifetime ( copy self)
811
+ public func _extracting( first maxLength: Int ) -> Self {
812
+ extracting ( first: maxLength)
813
+ }
814
+
771
815
/// Returns a span over all but the given number of trailing elements.
772
816
///
773
817
/// If the number of elements to drop exceeds the number of elements in
@@ -784,13 +828,20 @@ extension Span where Element: ~Copyable {
784
828
/// - Complexity: O(1)
785
829
@_alwaysEmitIntoClient
786
830
@lifetime ( copy self)
787
- public func _extracting ( droppingLast k: Int ) -> Self {
831
+ public func extracting ( droppingLast k: Int ) -> Self {
788
832
_precondition ( k >= 0 , " Can't drop a negative number of elements " )
789
833
let droppedCount = min ( k, count)
790
834
let newSpan = unsafe Self( _unchecked: _pointer, count: count &- droppedCount)
791
835
return unsafe _override Lifetime ( newSpan, copying: self )
792
836
}
793
837
838
+ @available ( * , deprecated, renamed: " extracting(droppingLast:) " )
839
+ @_alwaysEmitIntoClient
840
+ @lifetime ( copy self)
841
+ public func _extracting( droppingLast k: Int ) -> Self {
842
+ extracting ( droppingLast: k)
843
+ }
844
+
794
845
/// Returns a span containing the final elements of the span,
795
846
/// up to the given maximum length.
796
847
///
@@ -808,7 +859,7 @@ extension Span where Element: ~Copyable {
808
859
/// - Complexity: O(1)
809
860
@_alwaysEmitIntoClient
810
861
@lifetime ( copy self)
811
- public func _extracting ( last maxLength: Int ) -> Self {
862
+ public func extracting ( last maxLength: Int ) -> Self {
812
863
_precondition ( maxLength >= 0 , " Can't have a suffix of negative length " )
813
864
let newCount = min ( maxLength, count)
814
865
let offset = ( count &- newCount) * MemoryLayout< Element> . stride
@@ -819,6 +870,13 @@ extension Span where Element: ~Copyable {
819
870
return unsafe _override Lifetime ( newSpan, copying: self )
820
871
}
821
872
873
+ @available ( * , deprecated, renamed: " extracting(last:) " )
874
+ @_alwaysEmitIntoClient
875
+ @lifetime ( copy self)
876
+ public func _extracting( last maxLength: Int ) -> Self {
877
+ extracting ( last: maxLength)
878
+ }
879
+
822
880
/// Returns a span over all but the given number of initial elements.
823
881
///
824
882
/// If the number of elements to drop exceeds the number of elements in
@@ -835,7 +893,7 @@ extension Span where Element: ~Copyable {
835
893
/// - Complexity: O(1)
836
894
@_alwaysEmitIntoClient
837
895
@lifetime ( copy self)
838
- public func _extracting ( droppingFirst k: Int ) -> Self {
896
+ public func extracting ( droppingFirst k: Int ) -> Self {
839
897
_precondition ( k >= 0 , " Can't drop a negative number of elements " )
840
898
let droppedCount = min ( k, count)
841
899
let offset = droppedCount &* MemoryLayout< Element> . stride
@@ -846,4 +904,11 @@ extension Span where Element: ~Copyable {
846
904
// lifetime of 'buffer'. Make the dependence explicit.
847
905
return unsafe _override Lifetime ( newSpan, copying: self )
848
906
}
907
+
908
+ @available ( * , deprecated, renamed: " extracting(droppingFirst:) " )
909
+ @_alwaysEmitIntoClient
910
+ @lifetime ( copy self)
911
+ public func _extracting( droppingFirst k: Int ) -> Self {
912
+ extracting ( droppingFirst: k)
913
+ }
849
914
}
0 commit comments