-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abac5df
commit 338122a
Showing
10 changed files
with
210 additions
and
177 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
GenIRExtensions/Sources/GenIRExtensions/Collection+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Collection+Extensions.swift | ||
// | ||
// | ||
// Created by Thomas Hedderwick on 30/03/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
// Largely based off the Collection.map impl in Swift | ||
public extension Collection { | ||
func asyncMap<T>(_ transform: (Element) async throws -> T) async rethrows -> [T] { | ||
let count = self.count | ||
if count == 0 { | ||
return [] | ||
} | ||
|
||
var result = [T]() | ||
result.reserveCapacity(count) | ||
|
||
for element in self { | ||
try await result.append(transform(element)) | ||
} | ||
|
||
return result | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../GenIRExtensions/DecodingExtensions.swift → ...GenIRExtensions/Decoding+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// | ||
// DecodingExtensions.swift | ||
// | ||
// | ||
// | ||
// Created by Thomas Hedderwick on 03/02/2023. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.