Skip to content

Commit d74b9a1

Browse files
committed
[stdlib] document unsafe behaviour for empty spans
1 parent 7ac6d15 commit d74b9a1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

stdlib/public/core/Span/RawSpan.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ extension RawSpan {
472472
/// during the execution of `withUnsafeBytes(_:)`.
473473
/// Do not store or return the pointer for later use.
474474
///
475+
/// Note: For an empty `RawSpan`, the closure always receives a `nil` pointer.
476+
///
475477
/// - Parameter body: A closure with an `UnsafeRawBufferPointer`
476478
/// parameter that points to the viewed contiguous storage.
477479
/// If `body` has a return value, that value is also

stdlib/public/core/Span/Span.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ extension Span where Element: ~Copyable {
622622
/// during the execution of `withUnsafeBufferPointer(_:)`.
623623
/// Do not store or return the pointer for later use.
624624
///
625+
/// Note: For an empty `Span`, the closure always receives a `nil` pointer.
626+
///
625627
/// - Parameter body: A closure with an `UnsafeBufferPointer` parameter
626628
/// that points to the viewed contiguous storage. If `body` has
627629
/// a return value, that value is also used as the return value
@@ -654,6 +656,8 @@ extension Span where Element: BitwiseCopyable {
654656
/// during the execution of `withUnsafeBytes(_:)`.
655657
/// Do not store or return the pointer for later use.
656658
///
659+
/// Note: For an empty `Span`, the closure always receives a `nil` pointer.
660+
///
657661
/// - Parameter body: A closure with an `UnsafeRawBufferPointer`
658662
/// parameter that points to the viewed contiguous storage.
659663
/// If `body` has a return value, that value is also

0 commit comments

Comments
 (0)