Skip to content

[stdlib] use a primary associated type #61093

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 1 commit into from
Jan 3, 2024
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
12 changes: 6 additions & 6 deletions stdlib/public/core/UnsafeBufferPointer.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ extension Unsafe${Mutable}BufferPointer {
/// by this function.
@inlinable
@_alwaysEmitIntoClient
public func initialize<C: Collection>(
fromContentsOf source: C
) -> Index where C.Element == Element {
public func initialize(
fromContentsOf source: some Collection<Element>
) -> Index {
let count = source.withContiguousStorageIfAvailable {
guard let sourceAddress = $0.baseAddress, !$0.isEmpty else {
return 0
Expand Down Expand Up @@ -814,9 +814,9 @@ extension Unsafe${Mutable}BufferPointer {
/// - Returns: An index one past the index of the last element updated.
@inlinable
@_alwaysEmitIntoClient
public func update<C: Collection>(
fromContentsOf source: C
) -> Index where C.Element == Element {
public func update(
fromContentsOf source: some Collection<Element>
) -> Index {
let count = source.withContiguousStorageIfAvailable {
guard let sourceAddress = $0.baseAddress else {
return 0
Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/core/UnsafeBufferPointerSlice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,9 @@ extension Slice {
/// initialized by this function.
@inlinable
@_alwaysEmitIntoClient
public func initialize<C: Collection>(
fromContentsOf source: C
) -> Index where Base == UnsafeMutableBufferPointer<C.Element> {
public func initialize<Element>(
fromContentsOf source: some Collection<Element>
) -> Index where Base == UnsafeMutableBufferPointer<Element> {
let buffer = Base(rebasing: self)
let index = buffer.initialize(fromContentsOf: source)
let distance = buffer.distance(from: buffer.startIndex, to: index)
Expand Down Expand Up @@ -833,9 +833,9 @@ extension Slice {
/// - Returns: An index one past the index of the last element updated.
@inlinable
@_alwaysEmitIntoClient
public func update<C: Collection>(
fromContentsOf source: C
) -> Index where Base == UnsafeMutableBufferPointer<C.Element> {
public func update<Element>(
fromContentsOf source: some Collection<Element>
) -> Index where Base == UnsafeMutableBufferPointer<Element> {
let buffer = Base(rebasing: self)
let index = buffer.update(fromContentsOf: source)
let distance = buffer.distance(from: buffer.startIndex, to: index)
Expand Down