Skip to content

Fix parameter, doc comments in Span family #82102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/public/core/Span/MutableRawSpan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ extension MutableRawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoad<T>(
fromByteOffset offset: Int = 0, as: T.Type
fromByteOffset offset: Int = 0, as type: T.Type
) -> T {
_precondition(
UInt(bitPattern: offset) <= UInt(bitPattern: _count) &&
Expand Down Expand Up @@ -269,7 +269,7 @@ extension MutableRawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoad<T>(
fromUncheckedByteOffset offset: Int, as: T.Type
fromUncheckedByteOffset offset: Int, as type: T.Type
) -> T {
unsafe _start().load(fromByteOffset: offset, as: T.self)
}
Expand All @@ -293,7 +293,7 @@ extension MutableRawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoadUnaligned<T: BitwiseCopyable>(
fromByteOffset offset: Int = 0, as: T.Type
fromByteOffset offset: Int = 0, as type: T.Type
) -> T {
_precondition(
UInt(bitPattern: offset) <= UInt(bitPattern: _count) &&
Expand Down Expand Up @@ -323,7 +323,7 @@ extension MutableRawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoadUnaligned<T: BitwiseCopyable>(
fromUncheckedByteOffset offset: Int, as: T.Type
fromUncheckedByteOffset offset: Int, as type: T.Type
) -> T {
unsafe _start().loadUnaligned(fromByteOffset: offset, as: T.self)
}
Expand Down
22 changes: 11 additions & 11 deletions stdlib/public/core/Span/RawSpan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ extension RawSpan {

/// Unsafely create a `RawSpan` over initialized memory.
///
/// The region of memory representing `byteCount` bytes starting at `pointer`
/// The region of memory representing `count` elements starting at `pointer`
/// must remain valid, initialized and immutable
/// throughout the lifetime of the newly-created `RawSpan`.
/// Failure to maintain this invariant results in undefined behaviour.
///
/// - Parameters:
/// - pointer: a pointer to the first initialized byte.
/// - byteCount: the number of initialized bytes in the span.
/// - count: the number of initialized elements in the span.
@unsafe
@_alwaysEmitIntoClient
@lifetime(borrow pointer)
Expand Down Expand Up @@ -561,7 +561,7 @@ extension RawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoad<T>(
fromByteOffset offset: Int = 0, as: T.Type
fromByteOffset offset: Int = 0, as type: T.Type
) -> T {
_precondition(
UInt(bitPattern: offset) <= UInt(bitPattern: _count) &&
Expand Down Expand Up @@ -592,7 +592,7 @@ extension RawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoad<T>(
fromUncheckedByteOffset offset: Int, as: T.Type
fromUncheckedByteOffset offset: Int, as type: T.Type
) -> T {
unsafe _start().load(fromByteOffset: offset, as: T.self)
}
Expand All @@ -616,7 +616,7 @@ extension RawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoadUnaligned<T: BitwiseCopyable>(
fromByteOffset offset: Int = 0, as: T.Type
fromByteOffset offset: Int = 0, as type: T.Type
) -> T {
_precondition(
UInt(bitPattern: offset) <= UInt(bitPattern: _count) &&
Expand Down Expand Up @@ -648,7 +648,7 @@ extension RawSpan {
@unsafe
@_alwaysEmitIntoClient
public func unsafeLoadUnaligned<T: BitwiseCopyable>(
fromUncheckedByteOffset offset: Int, as: T.Type
fromUncheckedByteOffset offset: Int, as type: T.Type
) -> T {
unsafe _start().loadUnaligned(fromByteOffset: offset, as: T.self)
}
Expand All @@ -664,14 +664,14 @@ extension RawSpan {
unsafe (self._pointer == other._pointer) && (self._count == other._count)
}

/// Returns the offsets where the memory of `span` is located within
/// Returns the offsets where the memory of `other` is located within
/// the memory represented by `self`
///
/// Note: `span` must be a subrange of `self`
/// Note: `other` must be a subrange of `self`
///
/// Parameters:
/// - span: a subrange of `self`
/// Returns: A range of offsets within `self`
/// - Parameters:
/// - other: a subrange of `self`
/// - Returns: A range of offsets within `self`
@_alwaysEmitIntoClient
public func byteOffsets(of other: borrowing Self) -> Range<Int>? {
if other._count > _count { return nil }
Expand Down
10 changes: 5 additions & 5 deletions stdlib/public/core/Span/Span.swift
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,12 @@ extension Span where Element: ~Copyable {
unsafe (self._pointer == other._pointer) && (self._count == other._count)
}

/// Returns the indices within `self` where the memory represented by `span`
/// is located, or `nil` if `span` is not located within `self`.
/// Returns the indices within `self` where the memory represented by `other`
/// is located, or `nil` if `other` is not located within `self`.
///
/// Parameters:
/// - span: a span that may be a subrange of `self`
/// Returns: A range of indices within `self`, or `nil`
/// - Parameters:
/// - other: a span that may be a subrange of `self`
/// - Returns: A range of indices within `self`, or `nil`
@_alwaysEmitIntoClient
public func indices(of other: borrowing Self) -> Range<Index>? {
if other._count > _count { return nil }
Expand Down