Skip to content
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

Provide more type information on the JSONObject Parser #343

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion Sources/swift-parsing-benchmark/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ let jsonSuite = BenchmarkSuite(name: "JSON") { suite in
struct JSONObject: ParserPrinter {
var body: some ParserPrinter<Substring.UTF8View, [String: JSONValue.Output]> {
"{".utf8
Many(into: [String: JSONValue.Output]()) { object, pair in
Many(into: [String: JSONValue.Output]()) { (
object: inout [String: JSONValue.Output],
pair: (String, JSONValue.Output)
) in
let (name, value) = pair
object[name] = value
} decumulator: { object in
Expand Down
5 changes: 4 additions & 1 deletion Tests/ParsingTests/OneOfTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ final class OneOfTests: XCTestCase {
struct JSONObject: ParserPrinter {
var body: some ParserPrinter<Substring.UTF8View, [String: JSONValue.Output]> {
"{".utf8
Many(into: [String: JSONValue.Output]()) { object, pair in
Many(into: [String: JSONValue.Output]()) { (
object: inout [String: JSONValue.Output],
pair: (String, JSONValue.Output)
) in
let (name, value) = pair
object[name] = value
} decumulator: { object in
Expand Down