Skip to content

Commit 11db3ce

Browse files
author
Matthew Judy
committed
Update template to use async lines API.
1 parent 5064cc7 commit 11db3ce

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Template/ChallengeName.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Shared
1818
<#Challenge Documentation#>
1919
*/
2020
@main
21-
struct <#ChallengeName#>: ParsableCommand
21+
struct <#ChallengeName#>: AsyncParsableCommand
2222
{
2323
/// <#Enumeration for argument which activates "Part Two" behavior#>
2424
enum Mode: String, ExpressibleByArgument, CaseIterable
@@ -36,12 +36,10 @@ struct <#ChallengeName#>: ParsableCommand
3636

3737
extension <#ChallengeName#>
3838
{
39-
mutating func run() throws
39+
mutating func run() async throws
4040
{
41-
while let inputLine = readLine()
42-
{
43-
print("\(inputLine)")
44-
}
41+
let input: AsyncLineSequence = FileHandle.standardInput.bytes.lines // URL.homeDirectory.appending(path: "Desktop/input.txt").lines
42+
try await input.reduce(into: []) { $0.append($1) }.forEach { print($0) }
4543
}
4644
}
4745

0 commit comments

Comments
 (0)