Skip to content

Commit 10a0ee2

Browse files
committed
[stdlib] add an _extracting() overload for ClosedRange
1 parent 928cbea commit 10a0ee2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

stdlib/public/core/Span/RawSpan.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@ extension RawSpan {
421421
unsafe _extracting(unchecked: bounds.relative(to: byteOffsets))
422422
}
423423

424+
@_alwaysEmitIntoClient
425+
@lifetime(self)
426+
public func _extracting(
427+
unchecked bounds: ClosedRange<Int>
428+
) -> Self {
429+
let range = Range(
430+
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound&+1)
431+
)
432+
return unsafe _extracting(unchecked: range)
433+
}
434+
424435
/// Constructs a new span over all the bytes of this span.
425436
///
426437
/// The returned span's first byte is always at offset 0; unlike buffer

stdlib/public/core/Span/Span.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,17 @@ extension Span where Element: ~Copyable {
588588
unsafe _extracting(unchecked: bounds.relative(to: indices))
589589
}
590590

591+
@_alwaysEmitIntoClient
592+
@lifetime(self)
593+
public func _extracting(
594+
unchecked bounds: ClosedRange<Index>
595+
) -> Self {
596+
let range = Range(
597+
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound&+1)
598+
)
599+
return unsafe _extracting(unchecked: range)
600+
}
601+
591602
/// Constructs a new span over all the items of this span.
592603
///
593604
/// The returned span's first item is always at offset 0; unlike buffer

0 commit comments

Comments
 (0)