1
1
mirror of https://github.com/github/semantic.git synced 2025-01-01 11:46:14 +03:00

Move diff equality into Diff.swift.

This commit is contained in:
Rob Rix 2015-10-01 11:34:17 -04:00
parent 8bac863ca0
commit fb247732cc
2 changed files with 12 additions and 11 deletions

View File

@ -111,3 +111,15 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
return Array(diff(Stream(sequence: a), Stream(sequence: b)).map { $0.0 })
}
}
public func == (left: Diff, right: Diff) -> Bool {
switch (left, right) {
case let (.Patch(a1, b1), .Patch(a2, b2)):
return a1 == a2 && b1 == b2
case let (.Copy(a), .Copy(b)):
return a == b
default:
return false
}
}

View File

@ -19,17 +19,6 @@ public func == <F: Equatable, A: Equatable> (left: Syntax<F, A>, right: Syntax<F
return equals(left, right, ==)
}
public func == (left: Diff, right: Diff) -> Bool {
switch (left, right) {
case let (.Patch(a1, b1), .Patch(a2, b2)):
return a1 == a2 && b1 == b2
case let (.Copy(a), .Copy(b)):
return a == b
default:
return false
}
}
public func == (left: Doc, right: Doc) -> Bool {
switch (left, right) {
case (.Empty, .Empty), (.Line, .Line):