Change `Pair` to generic

This commit is contained in:
Norio Nomura 2016-12-21 14:14:18 +09:00
parent 37de487637
commit 499831cd26
No known key found for this signature in database
GPG Key ID: D4A7318EB7F7138D
2 changed files with 6 additions and 6 deletions

View File

@ -10,15 +10,15 @@ import Foundation
public enum Node {
case scalar(String, Tag)
case mapping([Pair], Tag)
case mapping([Pair<Node>], Tag)
case sequence([Node], Tag)
}
public struct Pair: Equatable {
let key: Node
let value: Node
public struct Pair<Value: Equatable>: Equatable {
let key: Value
let value: Value
init(_ key: Node, _ value: Node) {
init(_ key: Value, _ value: Value) {
self.key = key
self.value = value
}

View File

@ -167,7 +167,7 @@ extension Parser {
}
private func loadMapping(from firstEvent: Event) throws -> Node {
var pairs = [Pair]()
var pairs = [Pair<Node>]()
var event = try parse()
while event.type != YAML_MAPPING_END_EVENT {
let key = try loadNode(from: event)